Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A....Write a function that takes an array of ints, and the size of the array - a

ID: 3688185 • Letter: A

Question

A....Write a function that takes an array of ints, and the size of the array - another int. It also returns a double. Call this one 'average.' Return a double that is the average of the values in the array. Demonstrate that it works by finding the average of an array with these values {78, 90, 56, 99, 88, 68, 92} B......Write a function that takes one double parameter, and returns a char. The parameter represents a grade, and the char represents the corresponding letter grade. If you pass in 90, the char returned will be 'A'. If you pass in 58.67, the char returned will be an etc. Use the grading scheme on the syllabus for this course to decide what letter to return. C....Write a function that takes 3 int arguments and returns the largest of the 3.

Explanation / Answer

-> Function is nothing but a module for performing a particular task.

A) function for calculating average of given numbers.

double average(int a[],int s)
{
int i=0,sum=0;
while(i<s)
{
sum = sum + a[i];
}
return (double)(sum/s);
}

-> average function takes n values and finds the average of those values.

-> consider an example of array {78,90,56,99,88,68,92}

initially sum=0;

next sum =sum + 78 = 78;

next sum = sum + 90 = 78 + 90 = 168

next sum = sum + 56 = 168 + 56 = 224

next sum = sum + 99 = 224 + 99 = 323

next sum = sum + 88 = 323 + 88 = 411

next sum = sum + 68 = 411 + 68 = 479

next sum = sum + 92 = 479 + 92 = 571

average = 571 / 7 = 81.375 is returned to the called function,

B)function for returning grade

char grade(double b)
{
if(b>=90 && b<=100)
return 'A';
else if(b>=80 && b<90)
return 'B';
else if(b>=70 && b<80)
return 'C';
else if(b>=65 && b<70)
return 'D';
else if(b>=60 && b<65)
return 'E';
else if(b>=40 && b<60)
return 'F';
}

-> from this function a student enters his/her average score then they known their grade.

C)Function for finding largest number among three numbers

int largest(int a,int b,int c)
{

if(a>b && a>c)
return a;
else if(b>c)
return b;
else return c;
}

=> above method returns the number which is largest among three numbers.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote