How to use switch control statement in C Language

Switch Control Statement

On this page

Switch Control Statement

Program to use Switch Control Statement in C Language

#include <stdio.h>
int main()
{
  int choice;
  printf("Enter your choice : ");
  scanf("%d", &choice);
  switch (choice)
  {
  case 1:
  {
      printf("first\n");
      break;
  }
  case 2:
  {
      printf("second\n");
      break;
  }
  case 3:
  {
      printf("third\n");
      break;
  }
  default:
  {
      printf("woring choice\n");
  }
  }
  return 0;
}

Output

Enter your choice : 3
third