Question: Please helppppp! The program should be done on C language. For this assignment, your mission is to write a program that plays the game of





For this assignment, your mission is to write a program that plays the game of Hangman. The game is to be played between two players. The program should ask for the names of the two players and do a coin toss to determine who goes first. If its head, player 1 goes first, otherwise player 2 goes first. Whoever goes first, has to think of a word which the other player has to guess in six attempts. The program should ask the player to enter the secret word. This will be followed by a screen clear (print a new line character 200-400 times). The other player has to guess this word.The program then prints out a row of dashes-one for each letter in the secret word-and asks the user to guess a letter. If the user guesses a letter that is in the word, the word is redisplayed with all instances of that letter shown in the correct positions, along with any letters correctly guessed on previous turns. If the letter does not appear in the word, the user is charged with an incorrect guess. The user keeps guessing letters until either (1) the user has correctly guessed all the letters in the word or (2) the user has made six incorrect guesses. Afterwards the roles switch, and we keep a record of the wins and losses. The game continues until we have a winner. For instance, if player 1 guesses the word while player 2 is unable to guess the word, then player 1 wins. If they both guess correctly or both are unable to guess in a round, the game goes to the round 2, and continues until we have a winner. See sample run below. Your program should exactly emulate the sample run. The users may enter uppercase or lowercase characters, but your program should not differentiate between them. As in ' H ' is equivalent to ' h '. Your solution should use functions. It should have at least 2 functions other than the main function. Sample run (User input in bold and italics) Enter player 1 name: Nazim Enter player 2 name: Sarah Coin toss to decide who goes first...and it's a head. Nazin goes first. Nazim, enter your seoret word? He1lo HLOTS OE NEW LINE SPACES Sarah, enter a letter: Wordi: Incorreet quesses: 1 Sarah, enter a letter: Word: _ e - - Incorrect guesses: 1 Saran, enter a letter: i Word: - 0 . . . Incorrect guesses: 2 Sarah, encer a letter: o Word: - e0 Incorrect guesses: 2 Sarah, enter a letter: h Wordt he 0 Incorrect guesses: 2 Sarah, enter a lettert 1 Word: h e 1 o Incorrect quesses: 2 Sarah wins! Sarah's turn. Sarah, enter your secret. word: meagre LOTS OE NEW LINE SPACES Nazim, enter a letter: Hord: Nazim, enter a letter: Word: _ e a _ e Incorrect guesses: 0 Nazim, enter a letter: i Word: _ e a _ _ e Incorrect guesses: 1 Nazim, enter a letter: 0 Word: _ e a _ e e Incorrect guesses: 2 Nazim, enter a letter: h Word: _ e a _. e Incorrect guesses: 3 Nazim, enter a letter: x Word: _ e a re Incorrect guesses: 3 Nazim, enter a letter: r Word: - e a - re Incorrect guesses: 3 Nazim, enter a letter: m Word: m e a re Incorrect guesses: 3 Nazim, enter a letter: g Word: me a gre Incorrect guesses: 3 Nazim wins! Score: Nazim: 1 Sarah: 1 We have a tie, another round! Nazia, enter your secret word: bamboozle *LOTS OE NEW LINE SPACES Sarah, enter a letter: a Word: a Incorrect guesses: 0 Sarah, enter a letter: e Word: a+ Incorrect guesses: 0 Sarah, enter a letter: 1 Word: _a _. Incorrect quesses: 1 Sarah, enter a letter: o Word: a+00,a Incorrect guesses: 1 Sarah, enter a letter: x Word: a00 Incorrect guesses: 2 Sarah, enter a letter: t Word: a0,0 Incorrect guesses: 3 Sarah, enter a letter: 1 Word: a001e Incorrect guesses: 3 Sarah, enter a letter: m Word: _ an 001 e Incorrect guesses: 3 Sarah, enter a letter: g Word: _ am - 0 - 1 e Incorrect guesses: 4 Sarah, enter a letter: p Word: am001e Incorrect guesses: 5 Sarah, enter a letter: f Word: am001e Incorrect guesses: 6 Sarah loses! Sarah's turn. Sarah, enter your secret word: timely WLOTS OE NEW LINE SPACES Nazim, enter a letter: a Word: Incorrect guesses: 1 Nazim, enter a letter: Word:. e e - Incorrect guesses: 1 Nazim, enter a letter: 1 Word: i - e - Incorrect guesses: 1 Nazim, enter a letter: 0 Word: _ 1 - e Incorrect quesses: 2 Nazim, enter a letter: t Word: tie Incorrect guesses: 2 Nazim, enter a letter: y Word: tiey Incorrect guesses: 2 Nazim, enter a letter: 1 Word: tie1y Incorrect guesses: 2 Nazim, enter a letter: Word: ti e 1y Incorrect guesses: 2 Nazim, enter a letter: m Word: t i m e ly Incorrect guesses: 2 Nazim wins! Score: Nazim: 2 Sarah: 1 Nazim wins
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
