第四章2
#include<stdio.h> int main(void) { int count,num; double grade,total; num=0; total=0; count=0; printf("Enter grade:"); scanf("%lf\n",&grade); 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 failures is %d",count); } else printf("grade average is 0\n"); return 0; }