The algorithm used in this assignment is called a binary search. After each guess, the algorithm cuts the number of possible answers to search in half.
Your program should start by printing instructions to the screen, explaining that the user should pick a number between 1 and 1000 and the computer will guess it in no more than 10 tries. It then starts making guesses, and after each guess it asks the user for feedback. The user should be instructed to enter -1 if the computer needs to guess a lower number, 0 if the computer guessed correctly, and 1 if the computer needs to guess a higher number.
When the program guesses correctly, it should report how many guesses were required. If the user enters an invalid response, the instructions should be repeated and the user allowed to try again. You may assume that the user never gives a false answer.
(Read the full assignment here)