Question: [GuessMe.c] Write a program that displays the results of multiple guesses. The user is prompted to enter a number between 0 and 3 (so 0,1,2,3)

[GuessMe.c] Write a program that displays the results of multiple guesses. The user is prompted to enter a number between 0 and 3 (so 0,1,2,3)

If the user guesses the right number, print out a message that says You guessed right. Otherwise, print out a message that says You guessed wrong.

Make sure that the user can only enter 0, 1 ,2, 3 and -1, and if they enter something else, prompt them for the correct input.

Allow the user to play repeatedly, until they enter a -1. Once the user enters -1, show him/her the total number of guesses, how many they got right, and how many they got wrong.

Call a module called guess which returns a random number between 0 and 3.

guess should have the following signature

int guess();

There should be no printfs in guess and do not use global variables.

Sample Execution:

Enter a guess from 0 to 3 or -1 to quit: 5

Invalid Input.

Enter a guess from 0 to 3 or -1 to quit: -11

Invalid Input.

Enter a guess from 0 to 3 or -1 to quit: 0

You guessed wrong.

Enter a guess from 0 to 3 or -1 to quit: 0

You guessed right.

Enter a guess from 0 to 3 or -1 to quit: -1

You had 2 guesses

You got 1 right

You got 1 wrong.

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!