C Program to Print Days of Week in Words using If Else Ladder Statement

In this C program, we will learn how to print days of week in words using if else ladder 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 if else ladder statement to print name of day in words.

Required Knowledge


C program to print days of week in words

#include <stdio.h> 
  
int main() {  
    int day;   
 
    printf("Enter Day Number\n");  
    scanf("%d", &day);  

    /* Input Validation */
    if(day < 1 || day > 7){
     printf("Invalid Input !!!!\n");
     return 0;
    }
 
    if(day == 1) {  
        printf("Monday\n");  
    } else if(day == 2) {  
        printf("Tuesday\n");  
    } else if (day == 3) {  
        printf("Wednesday\n");  
    } else if(day == 4) {  
        printf("Thursday\n");  
    } else if(day == 5) {  
        printf("Friday\n");  
    } else if(day == 6) {  
        printf("Saturday\n");  
    } else {  
        printf("Sunday\n");  
    }
  
    return 0;  
}
Output
Enter Day Number
4
Thursday
Enter Day Number
7
Sunday
Enter Day Number
12
Invalid Input !!!!

Related Topics
C Program to Print Number of Days in a Month using If Else Ladder Statement
C Program to Enter Cost Price and Selling Price and Calculate Profit or Loss
C Program to Check Whether a Triangle is Valid or Not given Sides of Triangle
C Program to Find Total, Average and Percentage Marks of Subjects
C Program to Calculate Compound Interest
C Program to Find Maximum of Three Numbers using Conditional Operator
C program to find hcf and lcm of two numbers
C program to check armstrong number
C Program to Read an Amount and Find Number of Notes
List of all C programs