Introduction: In previous article i explained Else if ladder or multiple else if to check the month corresponding to number in C++ Language. In
this article i will explain how to check the day corresponding to the
entered number using ladder else if or we can say multiple else if in C++
language.Let's understand by creating a program.
#include<conio.h>
#include<conio.h>
#include<iostream.h>
main()
{
int num;
cout<<"Enter any
number between 1 to 7 : ";
cin>>num;
if(num==1)
{
}
else if(num==2)
{
cout<<"TUESDAY";
}
else if(num==3)
{
cout<<"WEDNESDAY";
}
else if(num==4)
{
cout<<"THURSDAY";
}
else if(num==5)
{
cout<<"FRIDAY";
}
else if(num==6)
{
cout<<"SATURDAY";
}
else if(num==7)
{
cout<<"SUNDAY";
}
else
{
cout<<"INVALID NUMBER
...PLEASE ENTER NUMBER BETWEEN 1 TO 7";
}
getch();
}
Run the program using Ctrl+F9
Output:
First Run
Enter any number
between 1 to 7: 2
TUESDAY
Second Run
Enter any number between 1 to 12: 5
FRIDAY
Third Run
Enter any number between 1 to 12 : 9
INVALID NUMBER ...PLEASE ENTER NUMBER BETWEEN 1 TO 7
If you have any question about any post, Feel free to ask.You can simply drop a comment below post or contact via Contact Us form. Your feedback and suggestions will be highly appreciated. Also try to leave comments from your account not from the anonymous account so that i can respond to you easily..