Home C Programming Language / Programs / Program to use switch statement. Display Monday to Sunday.
🚀 Programming Example

Program to use switch statement. Display Monday to Sunday.

👁 15,395 Views
💻 Practical Program
📘 Step Learning
Program to use switch statement. Display Monday to Sunday.

💻 Program Code

/* Program to use switch statement. Display Monday to Sunday.
  Author: Atnyla Developer */
  
#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
 
printf("enter m for Monday \nt for Tuesday\nw for Wednesday\nh for Thursday\nf for Friday\ns for Saturday\nu for Sunday \n");
printf("...............");
scanf("%c",&ch);

switch(ch)
{
case 'm':
case 'M': 
	printf("monday \n");
break;
case 't':
case 'T':
printf("tuesday \n");
break;
case 'w':
case 'W':
	printf("wednesday \n");
break;
case 'h':
case 'H':
	printf("thursday \n");
break;
case 'f ':
case 'F':
	printf("friday \n");
break;
case 's':
case 'S':
	printf("saturday \n");
break;
case 'u':
case 'U':
	printf("sunday \n");
break;
default: 
	printf("wrong input \n");
break;
}
getch();
}

                        

🖥 Program Output

enter m for Monday
t for Tuesday
w for Wednesday
h for Thursday
f for Friday
s for Saturday
u for Sunday
...............m
monday
Press any key to continue . . .
                            

📘 Explanation

Program to use switch statement. Display Monday to Sunday.
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.