In this program, we are going to print day name based on week no. Like – If the user enters 1 that means it is Monday.

Logic

After taking input (Week no) from the user, we have to compare that number with 1 to 7 or we can say comparing that number with a day of a week. So the logic goes like – if the number is equal to 1 then it is Monday, if the number is 2 then it is Tuesday etc… Like that we have to compare with each day of the week.

Program

#include <iostream>

using namespace std;

int main() {

    int weekday;

    cout << "Enter weekday day number (1-7) : ";
    cin >> weekday;

    if(weekday == 1) {

        cout << endl << "Monday";

    } else if(weekday == 2) {

        cout << endl << "Tuesday";

    } else if(weekday == 3) {

        cout << endl << "Wednesday";

    } else if(weekday == 4) {

        cout << endl << "Thursday";

    } else if(weekday == 5) {

        cout << endl << "Friday";

    } else if(weekday == 6) {

        cout << endl << "Saturday";

    } else if(weekday == 7) {

        cout << endl << "Sunday";

    } else {

        cout << endl << "Please enter weekday number between 1-7.";
    }
   
    return 0;
}

Output

Enter weekday day number (1-7) : 4
Thursday