Declare a 12-element int array named days. Assign the number of days in each month to the array, using 28 for February. Code the program so that it displays the number of days corresponding to the month number entered by the user. For example, when the user enters the number 7, the program should display the number 31. The program also should display an appropriate message when the user enters an invalid month number. Use a sentinel value to end the program.
#include<iostream>
usingnamespace std;
int main()
{
int num; // Stores the month the user wants to see how many days are in.
int days[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
cout << "Enter a number of the month to see the number of days in that month: ";
// getting the month the user wants to see the number of days in that month
cin >> num;
// decrementing num because arrays begin at 0.
num--;
// display days per month
cout << "Days of this month equal: " << days[num] << endl;
return 0;
}