Answer to Question #62467 in C for tennyson

Question #62467
write a programe that uses an array to store the marks of 50 students in a class.The program should also calculate and output the sum and average of the marks.
1
Expert's answer
2016-10-05T13:45:03-0400
#include <stdio.h>

double Av(double *scores, size_t n, double * sum);

int main(void)

{

printf("Hello World!\n");

const size_t n = 50;

double a[n];

double sum = 0;

for(size_t i = 0; i< n; i++)

scanf("%lf", &a[i]);

printf("\nave = %lf ", Av(a, n, &sum));

printf("sum = %lf\n", sum);

return 0;

}

double Av(double *scores, size_t n, double *sum)

{

double ave = 0;

for(size_t i = 0; i < n; i++){

ave += scores[i];

*sum += scores[i];

}

ave = ave / (double)n;

return ave;

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS