In C++ Program, we can write a code to input the number of week's days and convert it to the equivalent name of day of the week
This is done by using the switch selection statement in C++ if you want to learn about the selection statements read it here, What are Selection Statements in C++ .
Let's look at the code to input the number of week's days and convert it to the equivalent name of day of the week
#include <iostream.h>
using namespace std ;
int main ()
{
int dow ;
cout <<"Enter number of week's day(1-7) : " ;
cin >> dow;
switch (dow)
{
case 1 : cout<< "\n" <<"Sunday" ;
break ;
case 2 : cout<< "\n" <<"Monday" ;
break ;
case 3 : cout<< "\n" <<"Tuesday" ;
break ;
case 4 : cout<< "\n" <<"Wednesday" ;
break ;
case 5 : cout<< "\n" <<"Friday" ;
break ;
case 6 : cout<< "\n" <<"Saturday" ;
break ;
case 7 : cout<< "\n" <<"Wrong number of day" ;
break ;
}
return 0 ;
}
The output of the C++ Code