Write C program to print day of week name using switch case


Introduction

Write C program to print day of week name using switch case


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>
int main()
{
    int weeknumber;

    //Reading week no from user
    printf("Enter week number(1-7): ");
    scanf("%d", &weeknumber);

    switch(weeknumber)
    {
        case 1: printf("Monday");
            break;
        case 2: printf("Tuesday");
            break;
        case 3: printf("Wednesday");
            break;
        case 4: printf("Thursday");
            break;
        case 5: printf("Friday");
            break;
        case 6: printf("Saturday");
            break;
        case 7: printf("Sunday");
            break;
        default: printf("Invalid input! Please enter week no. between 1-7.");
    }
    return 0;
}

Result

C language

     





Related Topics




Popular Posts