4-2

#include<stdio.h>

int main(void)

{

         int count,num;

         double grade,total;

 

         num=0;

         total=0;

         count=0;

         printf("Enter grades:");

         scanf("%lf",&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\n",count);

         }

         else

                   printf("Grade average is 0\n");

 

                   return 0;

}

posted @ 2013-10-04 18:11  zhaoyang16  阅读(111)  评论(0编辑  收藏  举报