C++ Saved Program: kind-dog

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


#include <iostream>
using namespace std;

int main() {
    char n;
    long long int guess;
    cout << "Enter a number between 1 and 100: " << endl;
	long long int ma = INT_MAX;
	long long int mi = INT_MIN;
    guess = (ma + mi)/2;
    cout << "Is your number " << guess << "?" << endl;
	for (int i = 0; ;i++)
	{
	    cin >> n;
	    if (n == 's')
	    {
	        ma = guess;
	    }
	    else (n == 'e')
	    {
	        break;
	    }
	    else (n == 'l')
	    {
	        mi = guess;
	    }
	    cout << "Is your number " << (ma - mi) / 2 << "?" << endl;
	}
}
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs