23:
W.A.P. to read digits from 1 to 7 & prints days of week according to input.
Please follow me for more practicals....
Program:
#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int day;
printf("Enter the 'day' between 1 to 7 =
");
scanf("%d", &day);
switch (day)
{
case 1:
printf("\nThe day is
Monday");
break;
case 2:
printf("\nThe day is
Tuesday");
break;
case 3:
printf("\nThe day is
Wednesday");
break;
case 4:
printf("\nThe day is
Thursday");
break;
case 5:
printf("\nThe day is
Friday");
break;
case 6:
printf("\nThe day is
Saturday");
break;
case 7:
printf("\nThe day is
Sunday");
break;
default:
printf("\nWrong
Choice");
}
getch();
}
Output:
Enter the 'day'
between 1 to 7 = 6
The day is Saturday
Please follow me for more practicals....
Algorithm:
1.
START.
2.
Declare
day.
3.
Enter the
value of day.
4.
If (day
== 1) then display Monday else goto step 5.
5.
If (day
== 2) then display Tuseday else goto step 6.
6.
If (day
== 3) then display Wednesday else goto step 7.
7.
If (day
== 4) then display Thrusday else goto step 8.
8.
If (day
== 5) then display Friday else goto step 9.
9.
If (day
== 6) then display Saturday else goto step 10.
10. If (day == 7) then display Sunday else goto
step 11.
11. Display Wrong Entry.
12. STOP.
Please follow me for more practicals....
Flowchart: