How To Find Grade of a Student Using Switch Case In C Program

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

What is a Grade?

The grade is called 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 the grade of a student using a switch case is written.

C Program to Find Grade of a Student Using Switch Case

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

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 an F which means fail.

C

Outputs:

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

c program to find grade of a student using switch case

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

c program to find grade of a student using switch case

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

c program to find grade of a student using switch case

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

c program to find grade of a student using switch case

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

c program to find grade of a student using nested if else

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 for loop

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

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

C

Output:

c program to find grade of a student using switch case

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 the grade of a student using if-else statement.

Conclusion

In this way, we’ve learned about the c program to find the grade of a student using a 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 🙂


No comments