Question: (Game: hangman) in C++ Write a hangman game that randomly generates a word and prompts the user to guess one letter at a time, as

(Game: hangman) in C++

Write a hangman game that randomly generates a word and prompts the user to guess one letter at a time, as shown in the sample run. Each letter in the word is displayed in an asterisk. When the user makes a correct guess, the actual letter is then displayed. When the user finishes a word, display the number of misses and ask the user whether to continue for another word. Declare an array to store words, as follows:

// Use any words you wish

string words[] = {"write", "that", ...};

The following is a sample run:

(Guess) Enter a letter in word ******* > p

(Guess) Enter a letter in word p****** > r

(Guess) Enter a letter in word pr**r** > p

p is already in the word

(Guess) Enter a letter in word pr**r** > o

(Guess) Enter a letter in word pro*r** > g

(Guess) Enter a letter in word progr** > n

n is not in the word

(Guess) Enter a letter in word progr** > m

(Guess) Enter a letter in word progr*m > a

The word is program. You missed 1 time

Do you want to guess for another word? Enter y or n>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!