C Program to Print Days of Week in Words using Switch Case Statement

  • Write a C program to print name of days of week using switch case statement.

Required Knowledge

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.

C program to print name of day using switch case statement

#include <stdio.h> 
  
int main() {  
    int day;
    /* 
     * Take the Day number as input form user  
     */  
    printf("Enter Day Number (1 = Monday ..... 7 = Sunday)\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 (1 = Monday ..... 7 = Sunday)
4
Thursday
Enter Day Number (1 = Monday ..... 7 = Sunday)
7
Sunday
Enter Day Number (1 = Monday ..... 7 = Sunday)
12
Invalid Input !!!!

Related Topics
C program to find maximum of two numbers using switch statement
C program to check whether a character is vowel or consonant using switch statement
C program to find maximum of three numbers using conditional operator
C program to check decimal digit character using conditional operator
C program to print all factors of a number using for loop
C program to find product of digits of a number using while loop
C program to find all roots of quadratic equation
C program to count number of digits in an integer
C program to check a number is palindrome or not
List of all C programs