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.
#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!
Learn more about our help with Assignments:
C