Site icon Matistics

C – program to Input Marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer. Calculate the Percentage and Grade as per the grade system table

#include <stdio.h>
int main()
{
float p, c, m, b, comp, score, total, percentage;
// Maximum marks in all the subjects is 100.
printf("Enter the marks in physics ");

scanf("%f", &p);
printf("Enter the marks in chemistry ");
scanf("%f", &c);
printf("Enter the marks in math ");
scanf("%f", &b);
printf("Enter the marks in biology ");
scanf("%f", &m);
printf("Enter the marks in computer ");
scanf("%f", &comp);
score = p + c + m + b + comp;
percentage = (score / 500) * 100;
if (percentage >= 90)
{
printf("Grade AA");
}
else if (percentage >= 80)
{
printf("Grade AB");
}
else if (percentage >= 70)
{
printf("Grade BB");
}
else if (percentage >= 60)
{
printf("Grade BC");
}
else if (percentage >= 50)
{

printf("Grade CC");
}
else if (percentage >= 40)
{
printf("Grade CD");
}
else
{
printf("Grade FF");
}
return 0;
}
Exit mobile version