Coding Practice

Write a C program to input week number and print week day

Input week number and print week day
Sample Output
Enter week number(1 - 7): 1

Week number 1

1 for Saturday.

Process returned 0 (0x0)   execution time : 2.988 s
Press any key to continue.
Source Code
#include<stdio.h>
 
int main()
{
    char num;
 
    printf("Enter week number(1 - 7): ");
    scanf("%d", &num);
 
	// Start From Satureday = 1
    if(num == 1)
    {
        printf("\nWeek number %d\n\n%d for Saturday.\n", num, num);
    }
    else if(num == 2)
    {
        printf("\nWeek number %d\n\n%d for Sunday.\n", num, num);
    }
    else if(num == 3)
    {
        printf("\nWeek number %d\n\n%d for Monday.\n", num, num);
    }
    else if(num == 4)
    {
        printf("\nWeek number %d\n\n%d for Tuesday.\n", num, num);
    }
    else if(num == 5)
    {
        printf("\nWeek number %d\n\n%d for Wednesday.\n", num, num);
    }
    else if(num == 6)
    {
        printf("\nWeek number %d\n\n%d for Thursday.\n", num, num);
    }
    else if(num == 7)
    {
        printf("\nWeek number %d\n\n%d for Friday.\n", num, num);
    }
    else
    {
        printf("\nInvalid week number!\n");
    }
 
    return 0;
}
Sample Output
Enter week number(1 - 7): 3

Week number 3

3 for Monday.

Process returned 0 (0x0)   execution time : 1.441 s
Press any key to continue.
Change Theme
X