Program Assignment #4 Write a program that plays an interactive game of Hangman
ID: 3547464 • Letter: P
Question
Program Assignment #4
Write a program that plays an interactive game of Hangman with its user. In general, the
rules of Hangman are as follows:
? The object of the game is for the user to guess a secret word, given the number of
letters in the word. The number of letters is presented as a series of dashes or
underscores, like this: _ _ _ _ _ _
? At each turn, the user guesses one letter. If the guess is correct, the letter is
displayed in the correct position for the user to observe, like this: M _ _ M _ _
? If the guess is incorrect, the user
Explanation / Answer
234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 //hangman //Dylan Metz #include #include #include #include int main() { int const SIZE=20; //int const s=7; //char other[s]; char name[20]; char dash[SIZE]={" "}; char q; //The User's Guess int NumOfGuess=6; //Number of guesses int flag; //Open text file called hangman.txt ifstream myfile; myfile.open ("hangman.txt"); myfile>>name; for (int index = 0; index='A' && toupper(name[index])0; NumOfGuess--) { coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.