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;
}
Scroll to Top
logo
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.