C program to Find Grade of a Student

Write a C program to find Grade of a Student. For this, first, we have to calculate the Total, and Percentage of Five Subjects, or N number of subjects

C program to Find Grade of a Student Example

This program helps the user to enter five different values for five subjects. And then it will find the Total and Percentage of those Five Subjects in C.

For this program to Find Grade of a Student, we are using the Arithmetic Operators to perform arithmetic operations. Next, we used the Else If statement to check and display the Grade.

TIP: Else If statement checks for the first condition, if it is TRUE, then it will execute the statements present in that block. If the condition is FALSE, it will check the Next one (Else If condition) and so on.

#include <stdio.h>
 
int main()
{
    int english, chemistry, computers, physics, maths; 
    float Total, Percentage;
 
    printf(" Please Enter the Five Subjects Marks : \n");
    scanf("%d%d%d%d%d", &english, &chemistry, &computers, &physics, &maths);
 
    Total = english + chemistry + computers + physics + maths;
    Percentage = (Total / 500) * 100;
 
    printf(" Total Marks = %.2f\n", Total);
    printf(" Marks Percentage = %.2f", Percentage);
    
    if(Percentage >= 90)
    {
    	printf("\n Grade A");
	}
	else if(Percentage >= 80)
    {
    	printf("\n Grade B");
	}
	else if(Percentage >= 70)
    {
    	printf("\n Grade C");
	}
	else if(Percentage >= 60)
    {
    	printf("\n Grade D");
	}
	else if(Percentage >= 40)
    {
    	printf("\n Grade E");
	}
	else 
    {
    	printf("\n Fail");
	} 
    return 0;
}
C program to Find Grade of a Student 1

Let me try another student marks

 Please Enter the Five Subjects Marks : 
95
90
85
92
87
 Total Marks = 449.00
 Marks Percentage = 89.80
 Grade B