Course Content
Detailed Content of Programming in C
0/1
Introduction
0/1
Structure of C program
0/1
Answers of ‘C’ Pointers Programs
0/1
About Lesson

Write a program that takes a number (1 for Monday, 2 for Tuesday, etc.) as input and displays the corresponding day of the week using a switch statement. 

#include <stdio.h>

int main() {
int dayNumber;

// Taking input for the day number
printf(“Enter a number (1 for Monday, 2 for Tuesday, etc.): “);
scanf(“%d”, &dayNumber);

// Using a switch statement to determine the day of the week
switch (dayNumber) {
case 1:
printf(“Day of the week: Mondayn”);
break;
case 2:
printf(“Day of the week: Tuesdayn”);
break;
case 3:
printf(“Day of the week: Wednesdayn”);
break;
case 4:
printf(“Day of the week: Thursdayn”);
break;
case 5:
printf(“Day of the week: Fridayn”);
break;
case 6:
printf(“Day of the week: Saturdayn”);
break;
case 7:
printf(“Day of the week: Sundayn”);
break;
default:
printf(“Invalid day number. Please enter a number between 1 and 7.n”);
}

return 0;
}