I'm having trouble with my program.The program should use the random number generator (where I seed the generator, and only seed it once per program when i run it). My program's guess should narrow, as I tell it whether its guess is high or low.
For example, if the number I am thinking of in my head is 42, and the computer's first guess is 76, then I would tell the program that its guess is too high (you must provide prompts to the user indicating how he/she should respond, say "y" or "n", and you must then accept input from the keyboard accordingly). The program will then make a random guess between 1 and 75, since 76 and greater cannot possibly be the number I am thinking of. If the computer's second guess is 35, then I would tell the program that its guess is too low. Now the program will make a random guess between 36 and 75. The program should continue to narrow down its guesses until it determines the number you are thinking of. You should be sure to avoid any possible divide by zero condition.
You can try this way which resembles binary searching.
First, you initialize two variables, low and hi, to the lowest and the highest values of the range (0 and 99 in your example); then, you generate your first guess as "guess = (low + hi)/2".
Then you show it to the user. If the user replies that your guess is smaller, you update low as guess+1; if it's bigger, you update hi as guess -1.
Eventually the PC will guess it right in no more that ceil(log2(hi - low + 1)) + 1 tries.