在下面的代码中的朋友,我试图获得一些浮点数的平均值......我手动尝试我的ans应该是分数,但这里它是圆角图......请帮助我。
#include <stdio.h>
#include <stdlib.h>
//finding out the average marks for students ....
float average (float []);
int main()
{
int i;
float total_avg=0;
float arr_1[] = {10.2, 22.9, 36.04, 89.1, 94.1, 10.8,};
for(i=0; i<6; i++)
printf("%2f\n",arr_1[i]);
printf("\n\n");
total_avg = average (arr_1);
printf("Total average : %3f\n",total_avg);
system("PAUSE");
return 0;
}
float average (float a[5])
{
int sum = 0, i;
float total;
for(i=0; i<6; i++)
{
sum = sum+a[i];
}
total = sum/5;
return total;
}