Home > Computer Programming > Pseudocode for guessing game

Pseudocode for guessing game

September 4, 2013 Leave a comment Go to comments
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.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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