Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a C++ program that creates a two dimensional array to save the week days.

ID: 3583110 • Letter: W

Question

write a C++ program that creates a two dimensional array to save the week days. Then ask the user to enter a number between 0 and 6. The program should print the corresponding day.
((( use namespace std; ))) write a C++ program that creates a two dimensional array to save the week days. Then ask the user to enter a number between 0 and 6. The program should print the corresponding day.
((( use namespace std; ))) write a C++ program that creates a two dimensional array to save the week days. Then ask the user to enter a number between 0 and 6. The program should print the corresponding day.
((( use namespace std; )))

Explanation / Answer

#include <iostream>

using namespace std;
int main()
{
int num;
char day[7][20]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; //intialize 2D array with days
cout<<"Enter number between 0 and 6"<<endl;                               //prompt input number
cin>>num;                                                                   //read number
cout<<"The number '"<<num<<"' refers to day is " <<day[num];               //display output
  

return 0;
}

Output :

Enter number between 0 and 6
5
The number '5' refers to day is Friday