Answer to Question #168216 in C++ for sara

Question #168216

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.


1
Expert's answer
2021-03-02T08:03:00-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS