WAP that accepts marks of five subjects and finds percentage and prints grades according to the
WAP that accepts marks of five subjects and finds percentage and prints grades according to the
following criteria:
Between 90-100%--------------Print ‘A’
80-90%----------------------------Print ‘B’
60-80%---------------------------Print ‘C’
Below 60%----------------------Print ‘D’
following criteria:
Between 90-100%--------------Print ‘A’
80-90%----------------------------Print ‘B’
60-80%---------------------------Print ‘C’
Below 60%----------------------Print ‘D’
#include<stdio.h>
#include<conio.h>
void main()
{
float m1,m2,m3,m4,m5,percent;
clrscr();
printf("Enter the marks of the student in 5 subjects:\n");
scanf("%f%f%f%f%f",&m1,&m2,&m3,&m4,&m5);
percent=(m1+m2+m3+m4+m5)/5;
printf("\nPercentage=%f",percent);
if(percent>90.0 && percent<=100.0)
printf("\nGrade:A");
else if(percent>80.0 && percent<=90.0)
printf("\nGrade:B");
else if(percent>60.0 && percent<=80.0)
printf("\nGrade:C");
else
printf("\nGrade:D");
getch();
}
Output
Enter the marks of the student in 5 subjects:
80
92
94
84
78
Percentage=85.599998
Grade:B
No comments:
Post a Comment