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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started