This pseudo code outlines the logic for a hangman game program:
1. It initializes variables to track the hidden word, guessed letters, number of guesses remaining, and game status messages.
2. The main game loop gets a letter guess from the user and evaluates it, updating the display of the hidden word if correct.
3. If the full word is guessed, the user wins. Otherwise additional guesses are allowed until winning or losing all guesses.
1 of 3
Downloaded 73 times
More Related Content
Hangman Program
3. Hangman Program Pseudo Code
START evaluateGuess()
while sub < SIZE
Declarations
if guess = word[sub] then
num guess
guessCorrect = "Y"
string WORD[9] = M, I, C, R, O, S, O, F,
T showWord[sub] = word[sub]
string showWord[9] -, -, -, -,-, -, -, -, -, endif
string guessCorrect = N sub = sub + 1
string continueGame = Yes endwhile
num SIZE = 9
if guessCorrect = "Y" then
num sub = 0
string WELCOME Welcome to Guess the Hidden Word! output MSG_Match
Please enter a letter. if word[9] = showWord[9] then
string MSG_TRY_AGAIN Letters remain hidden. Please output MSG_Winner, showWord[9]
enter another letter or QUIT to quit." guess = "QUIT"
string MSG_NO_MATCH Sorry, Bad Guess! else
string MSG_MATCH Good_Guess! output The Hidden Word now looks like, showWord[9]
string MSG_WINNER = Congratulations, You are a
Winner! guessCorrect = "N"
You have guessed the Hidden Word: sub = 0
string BYE Thank You for Playing! Goodbye!" output TRY_AGAIN
getReady() input guess
while guess <> "QUIT" endif
evaluateGuess()
else
endwhile
output MSG_NO_MATCH
finish()
output The Hidden Word now looks like, showWord[9]
STOP sub = 0
output TRY_AGAIN
getReady() input guess
output WELCOME return
input guess
return
finish()
output BYE
return