请教:这个程序哪里出错了?为什么运行的结果那么奇怪呢?
#include<stdio.h>#include<ctype.h>
void main()
{
char answer='N';
double total=0.0;
double value=0.0;
int count=0;
printf("this program caculated the average of");
for( ;; )
{
printf("\nenter a value:");
scanf("%f",&value);
total+=value;
++count;
printf("do you want to enter another value?( N or Y ):");
scanf("%C",&answer);
if(tolower(answer)=='n')
break;
}
printf("\nthe average iS %.2f\n",total/count);
system("pause");
}
这个程序不能求平均值,为什么呢?