Skip to content
Home » C Program to Find Grade of Student Using Switch Statement

C Program to Find Grade of Student Using Switch Statement

Learn about C Program to Find Grade of Student Using Switch Statement in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

C Program to Find Grade of Student Using Switch Statement

Program:

#include<stdio.h>
int main()
{
   int score;

   printf("Enter score( 0-100 ): ");
   scanf("%d", &score);

   switch( score / 10 )
   {

   case 10:
   case 9:
     printf("Grade: A");
     break;

   case 8:
     printf("Grade: B");
     break;

   case 7:
     printf("Grade: C");
     break;

   case 6:
     printf("Grade: D");
     break;

   case 5:
     printf("Grade: E");
     break;

   default:
     printf("Grade: F");
     break;

   }

   return 0;
}

Output:

Enter score( 0-100 ): 96
Grade: A

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
C program to find the largest among three numbers using the conditional operator
program to enter two numbers. Make a comparison between them with the conditional operator in C