/* 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();
}
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 . . .
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.
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.