Q:

C Program to Find Grade of a Student Using Switch Case

belongs to collection: Switch Case Basic C Programs List

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.

``````#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;
}``````

Output:

Enter The Marks Between 0 To 100:

Enter The Mark: 95