// hi-low guesser
#include <iostream>
#include <string>
using namespace std;
const int
NUMBER_OF_GUESSES = 5;
int main()
{
string firstName;
int computerGuess;
int numGuesses = 5;
char answer;
int min;
int max;
cout << "please think of a number between 1 and 100, and I will try to." << endl;
cout << "guess the number in less than 7 attempts." << endl;
cout << "Press h if I've guessed too high or l if I've guessed too low." << endl;
computerGuess = 50;
while (numGuesses <= 5)
cout << "Is the number " <<
computerGuess << "?" << endl;
cin >> answer;
if (answer == 'l')
{ max = 100;
min = computerGuess + 1;
computerGuess = (max + min )/2;
numGuesses ++;}
else if (answer == 'h')
{ max = computerGuess + 1;
min = 0;
computerGuess = (max - 1)/2;
numGuesses ++;}
cout << " yes i guessed your number i win." << endl;
return 0;
}
kinda new to this thing so with sorry if im missing anything or did anything wrong .so my problem is quite obvious when you run the code through the compiler its a problem with my logic and i have been struggling to find out how to fix it for a while, if anybody can help just reply thanks