Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write in c program PSET 7 DESCRIPTION Write a program that generates a random number and asks the user to guess what the number is.

write in c program

image text in transcribed

image text in transcribed

PSET 7 DESCRIPTION Write a program that generates a random number and asks the user to guess what the number is. If the user's guess is higher than the random number, the program should display "Too high, try again." If the user's guess is lower than the random number, the program should display "Too low, try again." The program should use a while-loop that repeats until the user correctly guesses the random number. Keep a count of the number of guesses that the user makes. When the user correctly guesses the random number, the program should display the number of guesses. Lastly, place your code for the Guessing Game into a Game-Loop, (a boolean controlled while-loop) such that the user can be asked if he would like to play another game. When the response is 'yes', execute the Game Code otherwise 'exit' the Game-Loop. Your output dialog should look similar to the following: ttttttt* ******** BEGIN a GAME I'm thinking of a number. Can you guess what it is? 50 No, that's too low. Guess again: 75 Sorry, that's too high. Guess again: 62 Sorry, that's too high. Guess again: 56 Sorry, that's too high. Guess again: 53 Sorry, that's too high. Guess again: 51 No, that's too low. Guess again: 52 Congratulations! You guessed it! I was thinking of the number 52. You got it right in 7 guesses. ******** END OF a GAME ******** Would you like to play another game ? ('y' or 'n'): Y ++++++++ ttttttt* BEGIN a GAME I'm thinking of a number. Can you guess what it is? 50 Sorry, that's too high. Guess again: 75 Sorry, that's too high. Guess again: 62 Sorry, that's too high. Guess again: 56 Sorry, that's too high. Guess again: 53 Sorry, that's too high. Guess again: 52 Sorry, that's too high. Guess again: 51 Sorry, that's too high. Guess again: 25 Sorry, that's too high. Guess again: 12 No, that's too low. Guess again: 18 Sorry, that's too high. Guess again: 15 Sorry, that's too high. Guess again: 13 Congratulations! You guessed it! I was thinking of the number 13. You got it right in 12 guesses. ******** END OF a GAME ******** Would you like to play another game ? ('y' or 'n'): n Demonstrate your program by playing at least 2 or 3 games. 'Paste' your console Dialog & Results from the Compiler Output Window and 'Paste' your Source Code from the compiler Source Code Window into the "SUBMISSION TEMPLATE for PROGRAMMING SET 7" -- and SUBMIT into CANVAS by the Due Date

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

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions