I am trying to create a game where a random integer between 1 and 10 is created and if the player guesses correct it says "win", if they guess too low it says "Too low, if they guess to high it says "Too high" BUT if they guess out of range it says "invalid guess".
My problem is that when the player enters a number within range, the last part of my If Else statement is still running (the invalid guess).
I need it to not run the last ELSE if the guess is within range.Code:
if (guess_number == random_integer)
cout << "You win! ";
else if (guess_number < random_integer)
cout << "Your guess was too low ";
else if (guess_number > random_integer)
cout << "Your guess was too high";
else ( (guess_number < 1) || ( guess_number > 10) );
cout << "invalid guess, needs to be between 1 and 10";