Write a program to play a guessing game trying to guess a random number between 1 and 100. Have the program generate a n

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Write a program to play a guessing game trying to guess a random number between 1 and 100. Have the program generate a n

Post by answerhappygod »

Write A Program To Play A Guessing Game Trying To Guess A Random Number Between 1 And 100 Have The Program Generate A N 1
Write A Program To Play A Guessing Game Trying To Guess A Random Number Between 1 And 100 Have The Program Generate A N 1 (187.89 KiB) Viewed 50 times
Write a program to play a guessing game trying to guess a random number between 1 and 100. Have the program generate a number between 1 and 100 (see below), and then have the user enter guesses trying to guess the number. Use a loop to continuously ask the user for their guess until they find the number or they enter 10 guesses. To generate a random number, you must include <stdlib.h> and <time.h> in your program and in the main write: srand(time(0); Iluse srand with now as the seed for true randomness int x = rand(); I/get a random number between 0 and RAND_MAX the captures below demonstrate one successful and one failed run EGAME: Guess the number between 0 and 100 Jenter your guess (10 guesses left): 50 g... need to go higher genter your guess (9 guesses left): 75 e... need to go higher enter your guess (8 guesses left): 85 ... need to go lower enter your guess (7 guesses left): 81 F... need to go higher Jenter your guess (6 guesses left): 82 SYES !! 82 that's it' Congratulations, you found the secret number !! 7You did it in 5 guesses. GAME: Guess the number between and 100 enter your guess (10 guesses left): 50 ... need to go lower enter your guess (9 guesses left): 50 ... need to go lower enter your guess (8 guesses left): 50 ... need to go lower enter your guess (7 guesses left): 25 ... need to go lower enter your guess (6 guesses left): 25 ... need to go lower enter your guess (5 guesses left): 25 ... need to go lower enter your guess (4 guesses left): 03 ... need to go higher enter your guess (3 guesses left): 13 ... need to go higher enter your guess (2 guesses left): 13 ... need to go higher enter your guess (1 guesses left): 13 10 guess limit exceeded. You lost. The secret number was: 16
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply