IDNLearn.com: Your destination for reliable and timely answers to any question. Ask your questions and receive reliable, detailed answers from our dedicated community of experts.
Ask the user to think of a number between zero and one hundred. Your goal is to guess the number in as few guesses as possible. The user will inform you if you guessed too high, low or correct. Start by always guessing the middle number 50. If the user informs you it’s too low, then try 75. If 50 was too high, then try 25. Always guess the middle of the range of numbers left. In doing so, the range of numbers will be cut in half after each guess. If done correctly, no more than 7 guesses are needed. Print out “you cheated” if you reach 7 guesses and are still wrong.
Sagot :
We appreciate your presence here. Keep sharing knowledge and helping others find the answers they need. This community is the perfect place to learn together. Find reliable answers at IDNLearn.com. Thanks for stopping by, and come back for more trustworthy solutions.