
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 :
(50+100)/2=75
if the number we guessed is greater than 75 then.
( 100 + 75)/2= 87
if the number is greater than 87 then,
(100+87)/2=98
if the number is less than 98 then,
(98+87)/2=92
if the number is greater than 92 then,
(98+92)/2=95
if the number we guessed is less than 95 then,
(95+92)/2=93
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:
high variable
low variable
mid variable
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.