Write a program to do the following: - Create an array to hold the days of the w
ID: 3935012 • Letter: W
Question
Write a program to do the following:- Create an array to hold the days of the week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
- Create a loop to print out the days of the week starting from the end of the array to the beginning. Example: Sunday, Saturday, Friday, Thursday, Wednesday, Tuesday, Monday
In C++ Write a program to do the following:
- Create an array to hold the days of the week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
- Create a loop to print out the days of the week starting from the end of the array to the beginning. Example: Sunday, Saturday, Friday, Thursday, Wednesday, Tuesday, Monday
In C++ Write a program to do the following:
- Create an array to hold the days of the week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
- Create a loop to print out the days of the week starting from the end of the array to the beginning. Example: Sunday, Saturday, Friday, Thursday, Wednesday, Tuesday, Monday
In C++
Explanation / Answer
Solution.cpp
#include <iostream>//header for input output function
using namespace std;//it tells the compiler to link std namespace
int main()
{//main function
string dayName[] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday","Sunday"};
cout<<" Printing the days of the week starting from the end of the array to the beginning. ";
for(int i=6;i>=0;i--)
cout<<dayName[i]<<endl;//printing days of week in reverse order
return 0;
}
output
Printing the days of the week starting from the end of the array to the beginning.
Sunday
Saturday
Friday
Thursday
Wednesday
Tuesday
Monday
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.