Pseudocode for guessing game

Select a random number
Get a guess from the user
While the guess is incorrect
    if it's too high then print "Try lower..."
    if it's too low then print "Try higher..."
    Get another guess from the user
print "Well done! You got it!"


Notice that I did not need to test the guess when I printed “Well done”. I didn’t need to “see” if the guess was right. I knew that if we had jumped out of the loop and were executing that last line, that the guess MUST be right.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s