Check The Programming Section
In this program, the number of the weekdays will be taken as input and days name will be printed as output using switch case. The required code is as follows:
#include<stdio.h>
int main(){
int days;
printf("Enter any number from 1-7::");
scanf("%d",&days);
switch(days){
case 1: printf("The day is Monday");
break;
case 2: printf("The day is Tuesday");
break;
case 3: printf("The day is Wednesday");
break;
case 4: printf("The day is Thursday");
break;
case 5: printf("The day is Friday");
break;
case 6: printf("The day is Saturday");
break;
case 7: printf("The day is Sunday");
break;
default: printf("Entered day is not valid");
}
}