Question: you are asked to write a C++ program using array that lets the user or the computer play a guessing game. The computer randomly picks
you are asked to write a C++ program using array that lets the user or the computer play a guessing game. The computer randomly picks a number in between 1 and 100, and then for each guess the user or computer makes, the computer informs the user whether the guess was too high or too low. The program should start a new guessing game when the correct number is selected to end this run (see the sample run below). the computer part will use a binary search algorithm. leave comments next to code to clarify what they are doing.
Check this example and see how to use functions srand(), time() and rand() to generate the random number by computer.
Example of generating and using random numbers:

Here is a sample run of the program: Would you like to (p)lay or watch the (c)omputer play? p Enter your guess in between 1 and 100. 45 Sorry, your guess is too low, try again. Enter your guess in between 1 and 100. 58 Sorry, your guess is too low, try again. Enter your guess in between 1 and 100. 78 Sorry, your guess is too high, try again. Enter your guess in between 1 and 100. 67 Sorry, your guess is too low, try again. Enter your guess in between 1 and 100. 70 Sorry, your guess is too high, try again. Enter your guess in between 1 and 100. 68 Sorry, your guess is too low, try again. Enter your guess in between 1 and 100. 69 Congrats, you guessed the correct number, 69. Would you like to (p)lay or watch the (c)omputer play or (q)uit? c The computer's guess is 50. Sorry, your guess is too high, try again. The computer's guess is 25. Sorry, your guess is too high, try again. The computer's guess is 13. Sorry, your guess is too low, try again. The computer's guess is 19. Sorry, your guess is too high, try again. The computer's guess is 16. Sorry, your guess is too low, try again. The computer's guess is 17. Congrats, you guessed the correct number, 17. Would you like to (p)lay or watch the (c)omputer play or (q)uit? q Press any key to continue
Example of generating and using random numbers: #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
