i have to write this program
Create a simple game program that guesses a number.
Ask the user to think of a number between 0 and 7. Then ask three yes or no questions and a binary search to discover the answer. Input and guard the users answer with an abort exit if they type something that is not yes or no. There might be eight blocks in your program, one for each of the possible answers. Do not use a loop. Your knowledge of binary numbers should help you with this.

I need some idea of where to start
i have been doing C programming for about 2 weeks and my teacher doesnt really teach just passes out assignments.
any help would be appreaciated
thanks chris

12 Years
Discussion Span
Last Post by Narue

>Do not use a loop.
Smack your teacher, he's an idiot.

>ask three yes or no questions and a binary search to discover the answer.
Do you know how binary search works? You start in the middle and divide the range by half for each yes or no answer. For example, say the number is 3. You start at 4 and ask if 4 is greater than the number. You get a yes answer and cut out all values greater than or equal to 4. Your range is now {0,1,2,3}. Pick the middle element (2 to be consistent with the choice of 4) and ask again. 2 is less than 3, so you cut out all values less than or equal to 2. That gives you the range {3}. You've found the answer in two questions. At most, it should take three questions to find the answer.

The only hard part is figuring out the steps to take at each question, but that's a problem solving issue that you need to work out yourself if you want to learn anything from this assignment.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.