OverIQ.com

C Program to find the student's grade

Last updated on September 24, 2020


The following is a C program to find the grade of the student based on the marks entered by the user.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/****************************************
 * C Program to find the student's grade
*****************************************/

#include<stdio.h> // include stdio.h
 
int main() 
{
    float marks;
    char grade;
 
    printf("Enter marks: ");
    scanf("%f", &marks);
    
    if(marks >= 90)
    {
        grade = 'A';
    }
    else if(marks >= 80 && marks < 90)
    {
        grade = 'B';
    }
    else if(marks >= 70 && marks < 80)
    {
        grade = 'C';
    }
    else if(marks >= 60 && marks < 70)
    {
        grade = 'D';
    }
    else if(marks >= 50 && marks < 60)
    {
        grade = 'E';
    }
    else 
    {
        grade = 'F';
    }
                    
    printf("Your grade is %c", grade);
    
    return 0;
}

Try it now

Expected Output:

1st run:

1
2
Enter marks: 92
Your grade is A

2nd run:

1
2
Enter marks: 75
Your grade is C