You are here

switch case in c

switch is a keyword of c language.

Example c program explaining use of switch

#include<stdio.h>
 
main()
{
   int n;
 
   printf("Enter a number from 1, 2 or 3.\n");
   scanf("%d", &n);
 
   switch(n)
   {
      case 1:
 
      case 2:
 
      case 3:
              printf("Thanks!\n");
              break;
 
      default:
              printf("You didn't did what i said.\n");
   }
 
   return 0;
}