Program of switch case Statement
If we have a entire if-else construct within either the body of an if statement or the body of an else statement, then this construct is known as nesting of if statementSyntax
case constant 1:statement-block-1;
break;
case constant 2:
statement-block-2;
break;
•••
case constant n:
statement-block-n;
break;
Program
#include<conio.h>
void main()
{
int day;
printf("enter day in numbers 1 to 7");
scanf("%d",&day);
switch(day)
{
case 1 :
printf("Monday");
break;
case 2 :
printf("tuesday");
break;
case 3 :
printf("wednesday");
break;
case 4 :
printf("thursady");
break;
case 5 :
printf("friday");
break;
case 6 :
printf("saturday");
break;
case 7 :
printf("sunday");
break;
default :
printf("invalid number");
break;
}
getch();
}
0 Comments