Is it possible to loop an if-else statement? How would such a thing be coded. Basically, this code allows the user to enter a value for a month. If it's not from 0-12 it asks the user to enter a new value. How could I get that to go through the if-else again to see if it's a valid number? Also, if I wanted to say if it's less than 0 it's invalid does that need to be it's own if statement or I could I somehow combine that with something else?
#include <iostream>
using namespace std;
int main ()
{
cout << "Please enter a numerical value of a month: ";
int month;
cin >> month;
if (month<=12)
{
cout << "A valid month has been entered.";
}
else
{
cout << "That is not a valid entry. Please enter a new value. ";
int month;
cin >> month;
}
return 0;
}