0
Write a progarm that gets the input from the user.
the program valid its tht input is between 1-12 .otherwise it prints an error message. if data is valid the program prints the name of the month corresponding to input.
1 Antwort
+ 1
#include <iostream>
#include <string>
using namespace std;
 int x;
 string month[] = {"January", "February", "March", "April", "May",
                       "June", "July", "August", "September", "October", "November", "December"};
int main()
{
    cout << "Enter a month number: ";
    cin >> x;
    if (x<=12 && x>=1)
    {
    cout << month[x-1] << endl;
        
    }
    else 
    {
        cout<< "Error ";
    }
    return 0;
}



