Exer6
#include
#include
float grade, average, items, sum;
float grade, average, items, sum;
void main(){
clrscr();
average=0;sum=0;do{
printf("Enter grade (-1 to exit): ");
scanf("%f", &grade);if((grade!=-1)&&(grade<=100)){items++;sum=sum+grade;}}
while(grade!=-1);
average=sum/items;
average=sum/items;
printf("Class Average: %.2f\n", average);
if((average>=95)&&(average<=100)){printf("Rating: A");}else if((average>=90)&&(average<=94)){printf("Rating: B");}else if((average>=85)&&(average<=89)){printf("Rating: C");}else if((average>=80)&&(average<=84)){printf("Rating: D");}else if((average>=75)&&(average<=79)){printf("Rating: E");}else if(average<=74){printf("Rating: FAILED");} getch();
if((average>=95)&&(average<=100)){printf("Rating: A");}else if((average>=90)&&(average<=94)){printf("Rating: B");}else if((average>=85)&&(average<=89)){printf("Rating: C");}else if((average>=80)&&(average<=84)){printf("Rating: D");}else if((average>=75)&&(average<=79)){printf("Rating: E");}else if(average<=74){printf("Rating: FAILED");} getch();
}
No comments:
Post a Comment