This application assists the user in determining which day of the week a given number between 1 and 7 corresponds to.
When a user enters a number, we match that number to a particular day using switch-case.
#include <stdio.h>
int main() {
int day;
// Asking user for a number
printf("Enter a number (1-7): ");
scanf("%d", &day);
// Finding the day of the week using switch-case
switch (day) {
case 1:
printf("Monday\n");
break;
case 2:
printf("Tuesday\n");
break;
case 3:
printf("Wednesday\n");
break;
case 4:
printf("Thursday\n");
break;
case 5:
printf("Friday\n");
break;
case 6:
printf("Saturday\n");
break;
case 7:
printf("Sunday\n");
break;
default:
printf("Invalid input. Please enter a number between 1 and 7.\n");
}
return 0;
}