Write a program to do the following Create an array to hold
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++
Solution
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
