My if/else statement isn't working properly within my while loop. If the user enters in a number NOT between 1 and 9 then the while statement should work and it should ask the user to re-enter a number but it's not?
int positionNumber = 1;
cout << "Please Enter A Position Number (1-9) To Place The X: ";
cin >> positionNumber;
while (positionNumber>=1 && positionNumber<=9)
{
if (positionNumber >= 1 && positionNumber <= 9) break;
else cout << "Please Enter A Position Number (1-9) To Place The X: ";
So your if and else statement aren't in the right position. So the if statement is already in play as its also the while loop.
So you could try something like
1 2 3 4 5 6 7 8 9 10 11 12
do
{
if (positionNumber >=1 && positionNumber <=9)
{
break;
}
else;
{
cout << "Please enter a Positon Number (1-9) to place the X:";
}
}while(positionNumber <=9)