Answered step by step
Verified Expert Solution
Question
1 Approved Answer
What to do Write a C program, that can guess any number between 1 and a maximum number by way of asking simple questions that
What to do Write a C program, that can guess any number between 1 and a maximum number by way of asking simple questions that can be answered with either 'Yes' or 'No'. The form of the questions asked is generally something like this: "Is your number greater than XXX?" XXX will need to be computationally determined by your program and is part of your program's logic The idea of the algorithm underlying your program's logic is that you continuously divide the range of numbers that contains the number to be guessed into two (roughly) equally sized sub-ranges and then determine which part the number to be guessed lies in using the simple kind of question mentioned above. Once you know in which range the number is, you cut the corresponding interval in half again, ask the question, cut the proper interval in half, ask, cut... you get the idea. You should convince yourself that your algorithm terminates when there is nothing to cut any more, which occurs exactly when the final interval has a length of 1, or, in other words, when the variables containing the smallest and the biggest number of the range contain the same number, which happens to be the number to be guessed I want you implement your program honoring these conventions What to do Write a C program, that can guess any number between 1 and a maximum number by way of asking simple questions that can be answered with either 'Yes' or 'No'. The form of the questions asked is generally something like this: "Is your number greater than XXX?" XXX will need to be computationally determined by your program and is part of your program's logic The idea of the algorithm underlying your program's logic is that you continuously divide the range of numbers that contains the number to be guessed into two (roughly) equally sized sub-ranges and then determine which part the number to be guessed lies in using the simple kind of question mentioned above. Once you know in which range the number is, you cut the corresponding interval in half again, ask the question, cut the proper interval in half, ask, cut... you get the idea. You should convince yourself that your algorithm terminates when there is nothing to cut any more, which occurs exactly when the final interval has a length of 1, or, in other words, when the variables containing the smallest and the biggest number of the range contain the same number, which happens to be the number to be guessed I want you implement your program honoring these conventions
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started