Deciding the day of week using switch-case construct in C++

Program :-

#include<iostream.h>
void main()
{
int day:
cout<<"Enter the number in between of 1 to 7 to get corresponding day :";
cin>>day;
switch(day)
{
      case 1: cout<<"Today is Sunday";
      break;
      case 2: cout<<"Today is Monday";
      break;
      case 3: cout<<"Today is Tuesday";
      break;
      case 4: cout<<"Today is Wednesday";
      break;
      case 5: cout<<"Today is Thursday";
      break;
      case 6: cout<<"Today is Friday";
      break;   
      case 7: cout<<"Today is Saturday";
      break; 
      default : cout<<"Not a valid day";
      break;
}
}


Output :-
Enter the numberin betweeen of 1 to 7 to get corresponding day :
3
Today is Tuesday

IF THE NUMBER IS NOT BETWEEN 1 TO 7 THE OUT PUT WILL BE 
 " Not a valid day "

Comments

Popular posts from this blog

How to make a snake game using notepad using html [ with pictures ]

Program to find Addition of "n" numbers useing for loop

how to speed up your internet using cmd [command prompt] with pictures [100% working]