#include <iostream.h>
#include <conio.h>
//Read a number and display weekday accordingly
void main( )
{
int day;
clrscr();
cout<<”Enter a number between 1..7\n”;
cin>>day;
switch (day)
{
case 1 : cout<<”Monday\n”;
break;
case 2 : cout<<”Tuesday\n”;
break;
case 3 : cout<<”Wednesday\n”;
break;
case 4 : cout<<”Thursday\n”;
break;
case 5 : cout<<”Friday\n”;
break;
case 6 : cout<<”Saturday\n”;
break;
case 7 : cout<<”Saturday\n”;
break;
default : cout<<”Invalid input\n”;
}
getch();
}
Output :
Enter a number between 1..7
5
Friday
#include <conio.h>
//Read a number and display weekday accordingly
void main( )
{
int day;
clrscr();
cout<<”Enter a number between 1..7\n”;
cin>>day;
switch (day)
{
case 1 : cout<<”Monday\n”;
break;
case 2 : cout<<”Tuesday\n”;
break;
case 3 : cout<<”Wednesday\n”;
break;
case 4 : cout<<”Thursday\n”;
break;
case 5 : cout<<”Friday\n”;
break;
case 6 : cout<<”Saturday\n”;
break;
case 7 : cout<<”Saturday\n”;
break;
default : cout<<”Invalid input\n”;
}
getch();
}
Output :
Enter a number between 1..7
5
Friday
0 comments:
Post a Comment