萌新求教,求平均数,如何循环i,为什么结果老是无穷
#include<stdio.h>#include<math.h>
int main()
{
float a[100];
float sum, average;
int i, n;
printf("请输入: \n");
scanf("%f", &a[i]);
for(int n = 0; n < i; n++)
{
scanf("%f", &a[i]);
i ++;
}
sum += a[n];
average = sum / i ;
printf("平均数为:%f\n", average);
return 0;
}