Write a progarm that gets the input from the user. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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.

3rd Sep 2016, 5:49 AM
angle aries
1 Answer
+ 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; }
3rd Sep 2016, 9:25 AM
milo99