Q:

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

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#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:

Enter week number(1-7): 6

Saturday

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write C program to create calculator using switch ... >>
<< Write C program to print number of days in a month...