I am trying to write a game where a person thinks of a digit between 1 and 100 and computer has to guess it by asking you questions which you can only repond by typing '>', '<', or '='. What I wrote so far works only if the digit you think is 100 or 99. I can continue adding more lines in the program so that it covers all digits between 1 and 100, but seems like there should be a more efficient way of accomplishing this problem. If anyone knows of a better and faster way of doing it, please HELP. I will deeply appreciate that. Thanks a lot.

Arooj. Here is what I wrote:

#include <iostream.h>

#include <conio.h>

void main()

{

clrscr();

char ans;

cout << "Think of a number between 1 and 100 and I will\n"

"tell you the number that you thought.\n";

cout << "\nStrike any key when you are ready . . . . .";

getch();

clrscr();

cout << "\n\nOk, I am going to ask you a few questions and I just want you to\nrespond by entering '>' '<' or '=' as your answer.\n\n";

cout << "Is this number greater than, equal to, or or less than "

<< 50? ";

cin >> ans;

if (ans == '>')

{

cout << "\nIs the number greater than, equal to, or less than " << (51 + 100 / 2) << ": " ;

cin >> ans;

if (ans == '>'){

cout << "\nIs the number greater than, equal to, or less than " << (76 + 100) / 2 << ": " ;

cin >> ans;

if (ans == '>')

cout << "\nIs the number greater than, equal to, or less than " << (88 + 100) / 2 << ": " ;

cin >> ans;

if (ans == '>')

cout << "\nIs the number greater than, equal to, or less than " << (94 + 100) / 2 << ": " ;

cin >> ans;

if (ans == '>')

cout << "\nIs the number greater than, equal to, or less than " << (97 + 100) / 2 << ": " ;

cin >> ans;

if (ans == '>')

cout << "\nIs the number greater than, equal to, or less than " << (98 + 100) / 2 << ": " ;

cin >> ans;

if (ans == '>')

cout << "The number is 100. ";

else

cout << "The number is 99. ";

}

}

getch();

}