Loading...

Switch Case

Programme:

#include <stdio.h>
 
int main ()
{
   char grade = 'B';
 
   switch(grade)
   {
   case 'A' :
      printf("Excellent!\n" );
      break;
   case 'B' :
   case 'C' :
      printf("Amazing!!!\n" );
      break;
   case 'D' :
      printf("You passed\n" );
      break;
   case 'F' :
      printf("Better try again\n" );
      break;
   default :
      printf("Invalid grade\n" );
   }
   printf("Your grade is  %c\n", grade );
 
   return 0;
}

Output:

Amazing!!!
Your grade is  B