guessing a number
There is a program in which i am facing difficulties.
The question is that the user thinks of a number and the
computer guesses it. We have to guess the numbers from
1 to 100. If we guess 93 in our mind then we'll have to do
this step :
if the number we guessed is greater than 75 then.
( 100 + 75)/2= 87
if the number is greater than 87 then,
if the number is less than 98 then,
if the number is greater than 92 then,
if the number we guessed is less than 95 then,
93 was the number we guessed.
We have to take only '>' , '<' or '=' as inputs.
hope u understand.
try searching for binary search. but you will need:
do this in a loop. use if statements to check if the number is equal to, less than, or greater than and adjust the variables accordingly.