C Program to find grade
Check the grade of the students based on marks. First of all we will take input a mark of subject from the candidate and according to following condition we will calculate the grade.
Grade based on marks
- If marks <50 then Grade is F
- if marks >=50 <60 then Grade is D
- if marks >=60 <70 then Grade is C
- if marks >=70 <80 then Grade is B
- if marks >=80 <90 then Grade is A
- if marks >=90 then Grade is A+
Program to Calculate Grade According to marks
In following program we have taken one variables i.e mark. We will take input from the user and using if else condition we will calculate grade. in the following program in first condition we will print wrong entry if the marks is either less than 0 or greater than 100.
#include<stdio.h>
void main()
{
int marks;
printf("Enter your marks ");
scanf("%d",&marks);
if(marks<0 || marks>100)
{
printf("Wrong Entry");
}
else if(marks<50)
{
printf("Grade F");
}
else if(marks>=50 && marks<60)
{
printf("Grade D");
}
else if(marks>=60 && marks<70)
{
printf("Grade C");
}
else if(marks>=70 && marks<80)
{
printf("Grade B");
}
else if(marks>=80 && marks<90)
{
printf("Grade A");
}
else
{
printf("Grade A+");
}
}