In this C program, we will print name of days of week using switch case statement. We will take a number between 1 to 7 as input from user, where 1 corresponds to Monday, 2 corresponds to Tuesday and so on. We will use switch case statement to print name of day in words.
Required Knowledge
C program to print name of day using switch case statement
#include <stdio.h> int main() { int day; printf("Enter Day Number\n"); scanf("%d", &day); _ switch(day){ case 1 : printf("Monday\n"); break; case 2 : printf("Tuesday\n"); break; case 3 : printf("Wednesday\n"); break; case 4 : printf("Thursday\n"); break; case 5 : printf("Friday\n"); break; case 6 : printf("Saturday\n"); break; case 7 : printf("Sunday\n"); break; default: printf("Invalid Input !!!!\n"); } return 0; }Output
Enter Day Number 4 Thursday
Enter Day Number 7 Sunday
Enter Day Number 12 Invalid Input !!!!
Related Topics