In this problem, we have to find the day, let's take input as an example suppose the user enters 5(User input should be between 1 to 7 ) then our program will print the message on the screen " Today Is Friday ", and for other input, it will print the appropriate message on the screen. If the user thinks he is smart and he is trying to enter some other than values 1 to 7 then the program will print the message " Don't be Smart Wrong Choice Try Again!!!". the program will work only if values are 1 to 7.
C Program to Print Day of Week Name Using Switch Case
#include <stdio.h>
main()
{
/*c program to print days of week using switch */
int choice;
printf("Monday Will be First Days and So On\n\n");
printf("Enter Any Number Between (1 to 7):");
scanf("%d", &choice);
printf("\n");
switch (choice)
{
case 1:
printf("Today is Monday");
break;
case 2:
printf("Today is Tuesday");
break;
case 3:
printf("Today is Wednesday");
break;
case 4:
printf("Today is Thursday");
break;
case 5:
printf("Today is Friday");
break;
case 6:
printf("Today is Saturday");
break;
case 7:
printf("Today is Sunday");
break;
default:
printf("Don't Be Smart....Wrong Choice Try Again!!!");
}
getch();
}
0 Comments: