Question
Forgive me for my ignorance, I am just a beginner. So, I am working on a guessing game from 1-1000 using the binary search algorithm
Forgive me for my ignorance, I am just a beginner. So, I am working on a guessing game from 1-1000 using the binary search algorithm and I can't get the program to continue after the user enters their number. Just point me in the right direction and I will do the rest. Thank you very much! :-)
//Guessing Game
#include
using namespace std;
int main()
{
double min, max, mid, number;
cout << "Enter a number between 0 and 1000: " << endl;
cin >> number;
min = 0;
max = 1000;
while(min <= max);
{
mid = ((max - min)/2) + 0.5;
if(number < mid)
max = mid - 1;
else if(number > mid)
min = mid+1;
cout << mid;
}
cout << "Your number is " << mid << " ." << endl;
return 0;
}
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