Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions

Question

3. Maximize (the agreement function).

Answered: 1 week ago