Q>WAP to input day number of a week and display the corresponding
day name.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num;
cout<<"Enter day number of the week (1-7):";
cin>>num;
switch(num)
{
case 1:
{
cout<<"Monday";
break;
}
case 2:
{
cout<<"Tuesday";
break;
}
case 3:
{
cout<<"Wednesday";
break;
}
case 4:
{
cout<<"Thursday";
break;
}
case 5:
{
cout<<"Friday";
break;
}
case 6:
{
cout<<"Saturday";
break;
}
case 7:
{
cout<<"Sunday";
break;
}
default:
cout<<"Invalid choice";
}
getch();
}
day name.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num;
cout<<"Enter day number of the week (1-7):";
cin>>num;
switch(num)
{
case 1:
{
cout<<"Monday";
break;
}
case 2:
{
cout<<"Tuesday";
break;
}
case 3:
{
cout<<"Wednesday";
break;
}
case 4:
{
cout<<"Thursday";
break;
}
case 5:
{
cout<<"Friday";
break;
}
case 6:
{
cout<<"Saturday";
break;
}
case 7:
{
cout<<"Sunday";
break;
}
default:
cout<<"Invalid choice";
}
getch();
}
No comments:
Post a Comment