Answer:
#include <iostream>
using namespace std;
int main()
{
int day;
cout<<"Enter a number for the day of the week"<<endl;
cin>> day;
switch (day) {
case 1: cout << "Monday"<< endl; break;
case 2: cout << "Tuesday" << endl; break;
case 3: cout << "Wednesday" << endl; break;
case 4: cout << "Thursday" << endl; break;
case 5: cout << "Friday" << endl; break;
case 6: cout << "Saturday" << endl; break;
case 7: cout << "Sunday" << endl; break;
default: cout<<"Error, You entered an invalid day"<<endl;
}
return 0;
}
Explanation:
The program is written using a switch statement in C++ programming language. we start off by creating a variable day of type integer, which is received using the cin statement. We then use switch statement to test the value using the conditions stated in the question. We use the default statement which acts like an else statement to handle the an invalid situation