The switch statement tests the value of a given variable against a list of case values and when a match is found.a block of statement associated with that case is executed the following syntax of switch statement.
switch(expression)
{
case1:
statement1;
statement2;
break;
case2:
statement1;
statement2;
break;
case3:
statement1;
statement2;
break;
default:
statement;
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("Enter any Number From 1 to 3:");
scanf("%d",&a);
switch(a);
{
case1:
printf("One");
break;
case2:
printf("Two");
break;
case3:
printf("Three");
break;
default:
printf("Please Enter 1 to 3 Number:");
break;
}
getch();
}