C++ number-guessing game (computer tries to guess user's chosen number) In this program we input a number. Our PC tries to guess this number.

After every try PC asks us:"Are your number more or less than?".

We input 'l' if our number is less, and input 'h' if our number is greater?

A range of possible values ​​is created.  

I think this code is bad.  What do you think?

#include "stdafx.h"
#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &lt;ctime&gt;
using namespace std;

int Random(int min, int max) {
    return min + rand() % (max - min);
}

int main()
{
    setlocale(LC_ALL, "rus"); 
    int our_num;
    srand(static_cast&lt;unsigned int&gt;(time(0)));
    cout &lt;&lt; "Input a positive number: " &lt;&lt; endl;
    cin &gt;&gt; our_num;
    int t = 0;  //number of attempts
    int max = rand() + our_num;  //maximum possible value
    int min = 0;  //minimum possible value
    int d = Random(min, max);
    do {
        char lh;
        cout &lt;&lt; d &lt;&lt; " Is this your number?(my number is greater: 'h';   less: 'l')" &lt;&lt; endl;
        cin &gt;&gt; lh;
        ++t;
        if (lh == 'h') {
            min = d;
            d = Random(min, max);
        }
        else if (lh == 'l') {
            max = d;
            d = Random(min, max);
        }
    } while (d != our_num);
    cout &lt;&lt; "I guessed thus number with " &lt;&lt; t &lt;&lt; " attempts. " &lt;&lt; "This number is " &lt;&lt; d &lt;&lt; endl;
    return 0;
}
Some things stand out here:


Don't use using namespace std 
Consider not using rand()
Prefer using \n over std::endl
return 0 can be dropped from main as it's optional
You really need better variable names. Names should explain what the variable is used for. If you pick better names your superfluous comments can be removed alltogether