percentage and grade computer program |
PERCENTAGE
AND GRADE
Program number#
3
Program that determine percentage
and grade
Program:
void main ( )
{
int math, physic, chemistry, computer, total,
sum, percentage;
printf(“enter number obtained in math”);
scanf(“%d”, &math);
printf(“enter number obtained in physic”);
scanf(“%d”, &physic);
printf(“enter number obtained in chemistry”);
scanf(“%d”, &chemistry);
printf(“enter number obtained in computer”);
scanf(“%d”, &computer);
printf(“enter total number”);
scanf(“%d”,
&total);
sum=
math+ physic+ chemistry+ computer;
percentage=
sum/total*100;
if (percentage>
= 80)
printf(“A+”);
else if
(percentage > = 70 && percentage < =79)
printf(“A”);
else if
(percentage > = 60 && percentage < =69)
printf(“B”);
else if (percentage > = 50 && percentage
< =59)
printf(“C”);
else if (percentage > = 40 && percentage
< =49)
printf(“D”);
else if (percentage > = 33 &&
percentage < =39)
printf(“E”);
else if (percentage < =32)
printf(“FAIL”);
else
printf(“invalid numbers”);
}
0 comments:
Post a Comment
Please do not enter any spam link in the comment box