Write a program in c++ that inputs a number [1-12] from the user and displays the month. it also asks the user whether he wants to input another number or not, if the user inputs 1 then it again inputs number, if user inputs 0 then program ends.

want to see the answer

Sure! Here's a C++ program that does exactly what you described:

```cpp
#include <iostream>
using namespace std;

int main() {
int month;
int repeat;

do {
// Take input from user
cout << "Enter a number [1-12]: ";
cin >> month;

// Check validity of input
if (month >= 1 && month <= 12) {
// Display the corresponding month
switch (month) {
case 1:
cout << "January" << endl;
break;
case 2:
cout << "February" << endl;
break;
case 3:
cout << "March" << endl;
break;
case 4:
cout << "April" << endl;
break;
case 5:
cout << "May" << endl;
break;
case 6:
cout << "June" << endl;
break;
case 7:
cout << "July" << endl;
break;
case 8:
cout << "August" << endl;
break;
case 9:
cout << "September" << endl;
break;
case 10:
cout << "October" << endl;
break;
case 11:
cout << "November" << endl;
break;
case 12:
cout << "December" << endl;
break;
}
} else {
cout << "Invalid input!" << endl;
}

// Ask the user if they want to input another number
cout << "Do you want to enter another number? (1 for Yes, 0 for No): ";
cin >> repeat;

// Validate the repeat input
while (repeat != 0 && repeat != 1) {
cout << "Invalid input! Please enter 1 for Yes or 0 for No: ";
cin >> repeat;
}

} while (repeat == 1);

cout << "Program ended.";
return 0;
}
```

To explain the program, here are the key steps:

1. We define two integer variables to store the month input (`month`) and the repeat input (`repeat`).
2. We use a `do-while` loop to repeat the process until the user enters 0 to exit.
3. Inside the loop, we prompt the user to enter a number between 1 and 12.
4. We validate the input and display the corresponding month based on the input using a `switch` statement.
5. If the input is invalid, we display an error message.
6. We then ask the user if they want to enter another number (1 for Yes, 0 for No).
7. We validate the repeat input and repeat the loop if the input is 1 (Yes).
8. Finally, when the user enters 0 (No), we exit the loop and display a program end message.

You can compile and run this program to test it out.