Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

image text in transcribed

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

More Books

Students also viewed these Databases questions

Question

What is Larmors formula? Explain with a suitable example.

Answered: 1 week ago

Question

Consistently develop management talent.

Answered: 1 week ago

Question

Create a refreshed and common vision and values across Europe.

Answered: 1 week ago

Question

Provide the best employee relations environment.

Answered: 1 week ago