I am trying to write a code for number gusser using funcitons: The playOneGame function should have a return type of void. It should implement a complete guessing game on the ra
The guessing loop should loop something like this:
while (true)
{
int guess = getMidpoint(minimum, maximum);
std::cout << "\nIs it [h]igher/[l]ower/[e]qual to " << guess << "? ";
char answer;
if (!(std::cin >> answer))
{
std::cerr << "error reading user input, program exiting\n";
exit(1);
}
if (answer == 'h')
minimum = guess + 1;
else if (answer == 'l')
maximum = guess - 1;
else if (answer == 'e')
{
std::cout << "Well, isn't that nice.\n";
return;
}
if (minimum > maximum)
{
std::cerr << "hey, you lied to me!\n";
exit(1);
}
}