Friday, 5 July 2013

Enter any number and display the day of week using simple if construct.

#include<iostream>
using namespace std;
int main()
{
int day=0;
cout<<"Enter the day of the week you want to check: ";
cin>>day;
if(day==1)
{
cout<<"Day 1 is Monday";
}
if(day==2)
{
cout<<"Day 2 is Tuesday";
}
if(day==3)
{
cout<<"Day 3 is Wednesday";
}
if(day==4)
{
cout<<"Day 4 is Thursday";
}
if(day==5)
{
cout<<"Day 5 is Friday";
}
if(day==6)
{
cout<<"Day 6 is Saturday";
}
if(day==7)
{
cout<<"Day 7 is Sunday";
}
if(day!=1 && day!=2 && day!=3 && day!=4 && day!=5 && day!=6 && day!=7)
{
cout<<"Invalid choice";
}
}

No comments:

Post a Comment