Hi, i am writing a program that plays “guess what number I’m thinking of…” with you. User Inputs guesses and output whether the number is too low, too high, or right-on. I already wrote the program to have the user guess what number the computer is guessing; however, can anyone please help me on writing an algorithm to have the computer guess the user's number?
hawita
-3
Light Poster
Recommended Answers
Jump to PostHow would you guess the number? Write out those steps, and that's your algorithm.
It might be something along the lines of:
Pick a number halfway between the minimum and maximum possible numbers.
If correct, stop.
If too high, change possible maximum to this guess minus 1 and …
Jump to PostMoschops is saying you program the computer to do the same thing you do without the computer. What's your first guess? Make the computer to the same thing.
All 6 Replies
Moschops
683
Practically a Master Poster
Featured Poster
hawita
-3
Light Poster
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
Moschops
683
Practically a Master Poster
Featured Poster
hawita
-3
Light Poster
Moschops
683
Practically a Master Poster
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.