Write a program that displays the day of the week given an integer from 1 to 7. Start from Sunday. The integer should be given by the user.
#include <iostream>
using namespace std;
int main(){
int n;
cout<<"Enter number of day between 1 and 7\n";
cin>>n;
switch(n){
case 1: cout<<"Sunday";break;
case 2: cout<<"Monday";break;
case 3: cout<<"Tuesday";break;
case 4: cout<<"Wednesday";break;
case 5: cout<<"Thursday"; break;
case 6: cout<<"Friday"; break;
case 7: cout<<"Saturday"; break;
default: cout<<"Invalid number of day.";
}
return 0;
}
Comments
Leave a comment