1
0

c7-11.c 459 B

123456789101112131415161718
  1. #include <stdio.h>
  2. int main()
  3. {float average(float array[ ],int n);
  4. float score1[5]={98.5,97,91.5,60,55};
  5. float score2[10]={67.5,89.5,99,69.5,77,89.5,76.5,54,60,99.5};
  6. printf("The average of class A is %6.2f\n",average(score1,5));
  7. printf("The average of class B is %6.2f\n",average(score2,10));
  8. return 0;
  9. }
  10. float average(float array[ ],int n)
  11. {int i;
  12. float aver,sum=array[0];
  13. for(i=1;i<n;i++)
  14. sum=sum+array[i];
  15. aver=sum/n;
  16. return(aver);
  17. }