C Program to Find Grade of a Student Using Switch Case

Write a C Program to Find Grade of a Student Using Switch Case, The user needs to enter the subject number and the program must return the Grade of the subject based on the number. If a student enters the number between 90 to 100 then our program must return the Grade A or Excellent, similarly for other ranges numbers. To get the help I have a Number to grade conversion table this may help you to find the proper logic and roadmap for our program to Calculate Grade Using Switch Statement in C.

Logic: Calculate Grade Using Switch Statement in C

Logic is very simple to Calculate Grade Using Switch Statement in C. Taking input from the user(Input should be between range given 0 to 100 Else program play with you), as we know that grading system so divides the Mark by 10 and put the case condition in program See the below Explanation Step by step for better understanding.

Below is the number to Grade Conversion Table helps us to implements logic for C Program to Find Grade of a Student Using Switch Case.

Switch Case Grade Program in C Explanation

So first divide the mark by 10 so we can get a reminder and as you can see in the program we use case 4 to case 10. So if the remainder is between 4 to 10 our case performs the particular grade operation and display the result See the Step By Step Example for each case may be in this grade(Switch Case Grade Program in C) problem.

Case 1: If the user is over smart then there is a condition that if the mark given by the user is greater than 100 then our program displays the message "Don't Be Smart Enter your Marks Between Limit" or else part of the program will be performed.

Enter the Mark:- 1000
Output:- Don't Be Smart Enter your Marks Between Limit.

Case 2: If the user is entering the marks between the 0 to 100 and then the particular grade portion will be executed and display the output in the Console screen.

Enter the Mark:- 95

Now perform the same operation for Grade B, C, D, E, E-- and F. and write a C Program to Find Grade of a Student Using Switch Case.

Case 3: If Enter marks are not fulfilled the requirement of the case than the program will perform the default case.

Enter the Mark: 25
Output: You Grade Is: F or Fail

Required Knowledge: Format Specifiers, Switch Case.

Code: C Program to Find Grade of a Student Using Switch Case

``````#include<stdio.h>

int main()
{
int marks;
/*C Program to Find Grade of a Student Using Switch Case*/

printf("\n-----------------------------------");
printf("\nEnter The Marks Between 0 To 100:");

printf("\nEnter The Mark: ");
scanf("%d", &marks);

if(marks>100)
{
/* Marks greater than 100 */
printf("\nDon't Be Smart Enter your Marks Between Limit\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;
case 4 :
/* Marks between 40-59 */
break;
default :
/* Marks less than 40 */
printf("\n You Grade is: F or Fail\n");
}
}

getch();
return 0;
}``````

New: Grade of a Student Using Switch Case Output

Below you can find the source code output of C Program to Find Grade of a Student Using Switch Case.

Similar to Grade of a Student

Previous Post
Next Post

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.

2. Ankit Mishra04/03/2017, 01:05

Latest IDE's does not need headers
Like codeblocks
Che k it

1. Thanks Ankit Mishra

3. Does it work?

1. It's Working. Thanks for Visit

4. Instead of giving marks in input.. if I use grade in input like A and as output I want the marks limit 75-79. how can I found this type of output using codeblocks? plz help

5. The problem said clearly using switch-case. But your solution is using if-else?

1. Thanks for Comment This is why cause many people think they are smart, and they put marks upto 10000 and infinite. So if you Enter marks in subject is greater than 100 then the program will print a message. This is Just for Fun You Can remove and Modified.

Keep visiting Keep sharing

1. Hello,

You can modify or you can add as many conditions you want. This a just an example of my College grading System so there is No grading between 75 to 79 but you can put a case for according to your Query or you can send me a Query through email so I can provide a Full solution with respect to your Query.

Thanks For comment Keep visit keep share and Keep Healthy

7. Savage bro.. the first if condition statement which says to stay in limit

1. Why this is savage bro. This is because you are not able to get a simple code. This is a very simple problem in CPP "Grade Of Given Marks Using Switch Case". The First "IF" statement say stay in the limit cause, programmer like you think and they are smart so they enter a marks value greater than 100 ie 2000. Now take a deep breath and think about what will the output or grade of a student in this way you are going to get 1000%.

As we know that maximum marks you can get 100. This is the reason behind that the condition.

I Think now your doubt in clear Good luck in your career. Thanks for visiting

2. I think you can change the message. am I right?

3. Yes We can change, this is just a msg you can also change. Thanks for your comment

8. Thanks for sharing a awesome and well explain program in C++, I am following your website in long time nd always found new and complete working code. Thanks for everything and showing your support to newbie or new programmers.

1. Thanks for showing your support towards us. We try to make code well function and always try to solve and update a new as well as old code. Thanks again please share if you like our efforts.

9. I like the logic, If someone want to play with the program, he is not going to win. Thanks Bro. Happy Coding

10. http://www.svvideshvidya.com/

11. this is great

1. We all know this is a great website

12. This is a perfect solution of this problem

13. if 91-100=A & 81-90=B;then what is the code for this

14. what is the purpose of case 10:?

1. suppose student has 100 marks...

15. hello sir,
i m not able to execute this program in vs code. its showing error, pls suggest what should i do. i m a beginner in c.
regards

16. Write a program to find the grade of a student given his marks based on below:

90-100 A
80-90 B
70-80 C
60-70 D
<70 F