#include<stdio.h>
#include<ctype.h>
int main()
{ float sum=0.0;
int count=0;
float number;
char answer;
for(;;)
{
printf("\nenter a number:");
scanf("%f",&number);
sum+=number;
count++;
printf("Do you want to read and process some more(y/n):");
scanf("%c",&answer);
if(tolower(answer)=='n')
break;
}
printf("%f",sum/count);
return 0;
}
如果加了空格
见下面