/*计算平均成绩*/
#include<stdio.h>
int main(void)
{
int count,num; /*num记录输入的个数,count统计几个人数*/
double grade,total; /*分别存放成绩,成绩之和*/
num=0;
total=0;
count=0;
printf("Enter grades:
"); /*输入提示*/
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
",total/num);
printf("Number of pass a text is %d
",count);
}
else
printf("Grade average is 0
");
return 0;
}