![](//images0.cnblogs.com/blog/571388/201310/20131229-1b7f85fb775c4dd78a5f8f7d8a44027c.jpg)
/*计算平均成绩*/
#include<stdio.h>
int main(void)
{
int count,num; /*num记录输入的个数,count统计几个人数*/
double grade,total; /*分别存放成绩,成绩之和*/
num=0;
total=0;
count=0;
printf("Enter grades:\n"); /*输入提示*/
scanf("%lf",&grade); /*输入第一个数据*/
/*当输入数据大于等于0时,执行循环*/
while(grade>=0){
total=total+grade; /*累计成绩*/
num++; /*计数*/
if(grade>=60)
count++;
scanf("%lf",&grade); /*读入一个新数据,为下次循环做准备*/
}
if(num!=0){
printf("Grade average is %.2f\n",total/num);
printf("Number of pass a text is %d\n",count);
}
else
printf("Grade average is 0\n");
return 0;
}