I wrote a program where the computer will guess a random number between 1 and 100, and then it will play a guessing game against itself to try and guess that number. Based on how far away the guess is from the actual number, I have different if statements to give a hint at how far away the computer is. Based on that, the computer will try a different guess.
My question is this: I'm using a goto statement in each "if" statement because if the computer happens to guess the number correctly, it will not go through the "Is the number ___?" because the do while statement will break. I know people don't like goto statements, and this seems kind of messy to me, so I was wondering if there was a better way to do this?
My question is this: I'm using a goto statement in each "if" statement because if the computer happens to guess the number correctly, it will not go through the "Is the number ___?" because the do while statement will break
What? Why will the do/while() statement break?
Get rid if the goto statements, you don't need them since the code is already in a loop.