Hello at the moment I'm learning c++ and I've been working on a guessing game as practice but I need help. So far here is what i have made, but what I would like to know is how allow the player to be able to guess again if he/she choose a number that is too low or too high. Thanks.
You could use a loop to accomplish this. The code was altered, so I will explain what is changed in an edit.
EDIT: I began by enclosing the following in two curly brackets, thus creating a compound statement: the conditional statements (if statements) and instructions for user (guess the number of <player name>). I changed the if statements to a chain of if-else statements. If you hand't, then every condition would be evaluated. I added two break statements to the if statements that checked to see if a player had one. If a user guesses the correct number, the loop will break and the program will end once the return statement is reached.
EDIT2: I would normally use the while loop's condition to check to see if the user had guessed the correct number, but that introduces other problems in this situation. If the first player were to guess player 2's number, then the loop wouldn't break until the condition was evaluated. The while loop's condition is evaluated at the top of the compound statement. The use of a do-while loop wouldn't help eaither. Using the conditions in the both of these loops would still allow the second player to guess player one's number, even if player 1 had already correctly guessed player two's number.
To continually run the same code, we use things called Loops. These basically allow us to control the flow of our program.
There are 3 main types of loop. for loop, while loops and do while loops. All of these have been explained far better than I could do in this thread, a simple google will explain them all.
As for your problem, personally I would use a while loop.