Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer in C++ please COMP160 Guessing Game Write a program that asks the user to guess a number. The program should get a random number

Answer in C++ please image text in transcribed
COMP160 Guessing Game Write a program that asks the user to guess a number. The program should get a random number and count the number of times it takes the user to guess it. An easy way to get a random number is to use the randO function. You must \#include st hlib,h for this function. Before calling rand0, you will want to seed the random number generator. Otherwise it always makes the same random numbers. To create a random number from 1 to 100 srand(time(NULL)); 1/ seed the random number generator int target =rand() \& 100+1;// number to be guessed The program should continue to ask the user for a guess until they enter the correct number. If the guess is less than the target, display "Too low" and display "Too high" if the guess is larger than the target. Output from the program might look like the following (although your numbers will be different)

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

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

Develop a program for effectively managing diversity. page 303

Answered: 1 week ago

Question

List the common methods used in selecting human resources. page 239

Answered: 1 week ago