32.(C) Name of seven days of week using switch statement from code for win

 #include <stdio.h>

/*Write a C program to input week number(1-7)
and print day of week name using switch case.
C program to find week day name using switch case.
How to find day name of week using switch case in
C programming.*/
int main()
{
    int num;
    scanf("%d", &num);
    switch (num)
    {
    case 1:
        printf("Saturday\n");
        break;
    case 2:
        printf("Sunday\n");
        break;
    case 3:
        printf("Monday\n");
        break;
    case 4:
        printf("Tuesday\n");
        break;
    case 5:
        printf("Wednesday\n");
        break;
    case 6:
        printf("Thursday\n");
        break;
    case 7:
        printf("Friday\n");
        break;
    default:
        printf("Not valid date");
    }

    return 0;
}

Comments