In this tutorial, we’ll learn the c program to find grade of a student using switch case. We’ll also learn how we can find grade of a student using nested if-else statements. But, before starting the coding part we’ll see what actually the grade is. So,

The grade is called as the mark which indicates the quality of work done by any student or person. The grading system is used where we’ve to arrange the data of students in a particular order. Suppose, Teacher wants to find which student has scored the maximum marks in a class or wants to find how many students are passed and failed. In such a situation, the grading system is used.

In this tutorial, we’re using an Alphabetical grading system i.e A, B, C, D, etc. So let’s see how the c program to find grade of a student using switch case is written.

## C Program to Find Grade of a Student Using Switch Case

In this program we’ll write c program using switch case by referring to the below chart:

>=90A
80-89B
70-79C
60-69D
50-59E
<50F

From the above table, If student score marks >=90 then the grade will be given as A. Similarly, B grade for scoring marks between 80-89, Grade C for 70-79, Grade D for 60-69, Grade E for 50-59. If the student scores below 50 marks then the grade will be given as F which means fail.

```//Learnprogramo - Programming made simple
#include<stdio.h>
int main()
{
int marks;
// accept input from the user
printf("\nEnter the Marks Between 0 To 100:");
scanf("%d", &marks);

if(marks>100)
{
//If user enters marks greater than 100
printf("\nPlease Enter marks between 0 to 100\n");
}
else
{
switch(marks/10)
{
case 10 :
case 9 :
//Marks between 90-100
break;
case 8 :
// Marks between 80-89
break;
case 7 :
// Marks between 70-79
break;
case 6 :
// Marks between 60-69
break;
case 5 :
// Marks between 50-59
break;
default :
//Marks less than 50
printf("\n You Grade is: F & you're Failed\n");
}
}
return 0;
}```

Outputs:

1st Test Case: If the student score marks between 90 to 100 then the output will be Grade A.

2nd Test Case: If the student score marks between 80 to 89 then the output will be Grade B.

3rd Test Case: If the student score marks between 70 to 79 then the output will be Grade C.

4th Test Case: If the student score marks between 60 to 69 then the output will be Grade D.

5th Test Case: If the student score marks between 50 to 59 then the output will be Grade E.

6th Test Case: If the student score marks below 50 then the output will be Grade F and the student is failed the exam.

## C Program to Find Grade of a Student Using Nested if else

In this program, we’ll see how we can find grade of a student using nested if else statements.

```//Learnprogramo - Programming made simple
#include<stdio.h>
int main()
{
int marks;
printf("\nEnter the Marks Between 0 To 100:");
scanf("%d",&marks);
if(marks>=90 && marks<=100)
else if(marks>=80)
else if(marks>=70)
else if(marks>=60)
else if(marks>=50)
else
printf("Grade is: F & You're failed");
return 0;
}```

Output:

In the above output, I’ve entered marks as 55 so the grade I get is Grade E. So, in this way we’ve done the code for the C program to find grade of a student using if else statements.

## Conclusion

In this way, we’ve learned about the c program to find grade of a student using switch case. If you have any doubts related to code then please feel free to contact us. We’ll reply as soon as possible.

Thanks & Happy Coding 🙂