What is up with that crazy indentation?
Well anyway, you have a rather... silly means of restricting your input. I don't know what it is and somebody will probably bring up something obvious, but there's a better way to do it.
1 2 3 4 5 6 7 8
|
cout << "Let's have a number from 1 to 10 ";
cin >> thenum;
while (thenum < 1 || thenum > 10)
{
cout << "That's not a valid number. ";
cin >> thenum;
}
|
If you don't know yet, while is a conditional loop. It's, unlike for, designed to run as many times as it has to, and it could be indeterminate. The condition, if you don't recognize the || operator, basically means
"thenum less than one OR thenum greater than 10"
You can check the tutorial on this website for a full introduction, but that's the kind of code I use to check my input for validation. Try something like that and see what happens.