Question: 5. For 2 points extra credit, look up the binary search algorithm and answer the below questions. a. Explain how you could use a binary



5. For 2 points extra credit, look up the binary search algorithm and answer the below questions. a. Explain how you could use a binary search algorithm to win the number guessing game in problem 4 more easily. b. What is the maximum number of guesses that you would theoretically need in order to win the game in problem 4, if you used a binary search algorithm? 4. (5 points) Guessing a number in 7 tries or less: Modify the code provided in the following page so that the user has seven attempts to guess a random number between 0 and 100. If the user guesses the secret number with seven or fewer tries, the program should output You win!. If the user does not guess the number by the seventh try, the program should output "Game over! Try again!. See the next page for the code to modify. Note: This program uses random number generator and time libraries. Don't worry about learning those yet. Just modify the program as is. Some hints: 1) You will need to define an int variable to keep track of how many guesses have been used. 2) You will need to modify your while loop's conditional statement to also check whether the number of guesses is less than seven 3) You will need to add some statements to the while loop to increase the guess counting variable by 1 after each guess 4) Remember to use braces appropriately when you have multiple statements in an if statement. 5) You need to add an if statement at the end of the program to check whether the user has won or lost and output the appropriate response. Program to modify for question 3: #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
