Question: Iostream only Write a C++ program that asks a user to write down a number between 1 and 1000, inclusive and then proceeds to determine
Iostream only
Write a C++ program that asks a user to write down a number between 1 and 1000, inclusive and then proceeds to determine what that number is by displaying a number and asking if it is H)igh, L)ow or C)orrect. You can use what you know about the binary search to implement this algorithm. Your program should be able to determine the user's number in 10 "guesses" or less. Depending on the nuber of guesses, have the program make some smart remark. A Typical run might be:
Think of a number between 1 and 1000 Write it down, I will guess it is 500 H)igh, L)ow, or C)orrect? l is 750 H)igh, L)ow, or C)orrect? h is 625 H)igh, L)ow, or C)orrect? l is 687 H)igh, L)ow, or C)orrect? c Your number is 687 It seldom takes me this long!
Do you want to go again? Y or N
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
