program to accept number fron 1-7 and display the of days of week according to number.
void main()
{
int day;
clrscr();
printf("enter any number from 1-7=");
scanf("%d",&day);
switch(day)
{
case 1 :
printf("\n monday");
break;
case 2 :
printf("\n tuesday");
break;
case 3 :
printf("\n wednesday");
break;
case 4 :
printf("\n thursday");
break;
case 5 :
printf("\n friday");
break;
case 6 :
printf("\n saturday");
break;
case 7 :
printf("\n sunday");
break;
default :
printf("invalid number");
break;
}
getch();
}
output :
enter any number from 1-7=2
tuesday
or
enter any number from 1-7=8
invalid number