Random Number Generator game #include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &lt;ctime&gt;
#include &lt;string&gt;
using namespace std;
void wrapUp() {
    cout &lt;&lt; "-------------------------------------------------" &lt;&lt; endl;
    system("CLS");


}



int main() {
    srand(time(0));
    string name;
    int player;
    int livesTracker = 5;
    int x = 1 + (rand() % 10);

    cout &lt;&lt; "Hello, what is your name?" &lt;&lt; endl;
    cin &gt;&gt; name; 
    cout &lt;&lt; "Welcome to guess the number, " &lt;&lt; name &lt;&lt; "!" &lt;&lt; endl;
    wrapUp;
    cout &lt;&lt; '\n' &lt;&lt; "Number of Lives: " &lt;&lt; livesTracker &lt;&lt; endl;

    for (int round = 1; round &lt;= 3; round++) {

        if (livesTracker == 0) {
            system("CLS");
            cout &lt;&lt; "Game Over! Actual Answer: " &lt;&lt; x &lt;&lt; endl;
            system("Color 4");
            break;
        }

        cout &lt;&lt; "Guess the number that will come up on the screen from 1 to 10" &lt;&lt; endl;
        cin &gt;&gt; player;


        if (player == x) {
            cout &lt;&lt; "You won round " &lt;&lt; round &lt;&lt; "!" &lt;&lt; endl;
            x = (rand() &amp; 10);
        }
        else if(player &gt; x){

            cout &lt;&lt; "Your guess was too high, round" &lt;&lt; round &lt;&lt; "!" &lt;&lt; endl;
            wrapUp;
            round--;
            livesTracker--;
            cout &lt;&lt; '\n' &lt;&lt; "Number of Lives: " &lt;&lt; livesTracker &lt;&lt; endl;
        }
        else {
            cout &lt;&lt; "Your guess was too low, round" &lt;&lt; round &lt;&lt; "!" &lt;&lt; endl;
            wrapUp;
            round--;
            livesTracker--;
            cout &lt;&lt; '\n' &lt;&lt; "Number of Lives: " &lt;&lt; livesTracker &lt;&lt; endl;
        }


        if (round == 3) {

            cout &lt;&lt; "For the hard level, you have to guess a number from 15!" &lt;&lt; endl;
            for (int roundh = 1; roundh &lt;= 2; roundh++) {

                int xh = 1 + (rand() % 15);

                    cout &lt;&lt; "Guess the number that will come up on the screen from 1 to 15" &lt;&lt; endl;
                    cin &gt;&gt; player;

                if (player == xh) {

                    cout &lt;&lt; "You won round " &lt;&lt; roundh &lt;&lt; "!" &lt;&lt; endl;
                    cout &lt;&lt; "-------------------------------------------------" &lt;&lt; endl;
                    xh = 1 + (rand() % 15);
                }
                else if (player &gt; xh) {

                    cout &lt;&lt; "Your guess was too high, round " &lt;&lt; round &lt;&lt; "!" &lt;&lt; endl;
                    wrapUp;
                    roundh--;
                    cout &lt;&lt; '\n' &lt;&lt; "Number of Lives: " &lt;&lt; livesTracker &lt;&lt; endl;
                }
                else {
                    cout &lt;&lt; "Your guess was too low, round " &lt;&lt; round &lt;&lt; "!" &lt;&lt; endl;
                    wrapUp;
                    roundh--;
                    cout &lt;&lt; '\n' &lt;&lt; "Number of Lives: " &lt;&lt; livesTracker &lt;&lt; endl;
                }

            }

        }
    }



    system("pause");









}


This program first creates a random number before going into the loop. A livesTracker variable is then created to control the player's lives. The first loop runs until the player finishes the first round/ level. If the player gets the randomly generated number correct, a new random number will be assigned to x for the next round to start, until the player runs out of lives or wins the game, this will happen. 

Just wanted to explain the program because its probably too messy to read, appreciate any help!

EDIT: I know its not good to clear the screen using system("CLS"), but couldn't find any other options, any help on that would be helpful as well!
I have some suggestions to improve your code:



Formatting


You should use empty lines consistently. E.g. you have some ifs/else ifs blocks where you put an empty line at the beginning but not everywhere. I suggest you to not use empty lines there at all.
You should not use more than two empty lines to seperate things. It's harder to read.
You should put empty lines between logically grouped things. E.g. your #include statements, the using statement and the wrapUp function are glued together.
In general try to group things visually that belong together. In the wrapUp function the two empty lines are seperating the ending curly bracket from the function for no reason.
You should not put a newline as first thing you print in a line, e.g. cout &lt;&lt; '\n' &lt;&lt; "Number of Lives: " &lt;&lt; livesTracker &lt;&lt; endl;. And you should not mixup '\n' and endl.




Naming


You should name variables more precisely. player should be named playerGuess. This will make it much clearer what the variable is for. You may ask why this is relevant because you know it already but be aware of other developers. Just by putting that Guess at the end will remove the amount of time someone has to put in finding out stuff. Some other variables could use better naming as well, like roundh or livesTracker.
I think wrapUp does not describe well enough what it's doing. (That one is kinda personal taste.)




Functional


It's strange to put the game logic in a for loop and decrement the iterator to continue with the game. I know, I know, it works, but this is not the usual way to use a for loop. A while loop does fit here much better. When you connect the while loop to the amount of lifes left, you will have a much more readable code, e.g. while (amountOfLifes &gt; 0) {// continue with the game}.
The game logic for the normal game and the hard mode is very similar. You can put it in a method and use parameters, e.g. to individualize the range for the random number to guess.




Here is an example of how the program could look like when you apply my suggestions. It doesn't need to be exactly like that. Please note that I didn't double check everything and I changed some of the logic but I hope you get an overall idea about what is improvable:

#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &lt;ctime&gt;
#include &lt;string&gt;

using namespace std;


void printSeperator() {
    cout &lt;&lt; "-------------------------------------------------" &lt;&lt; endl;
}


bool guess(int&amp; lifesCounter, int numberToGuess, int round, int upperRandomLimit) {
    cout &lt;&lt; "Guess the number that will come up on the screen from 1 to " &lt;&lt; upperRandomLimit &lt;&lt; ": ";
    int playerGuess;
    cin &gt;&gt; playerGuess;

    if (playerGuess == numberToGuess) {
        cout &lt;&lt; "You won round " &lt;&lt; round &lt;&lt; "!" &lt;&lt; endl;
        printSeperator();
        return true;
    }
    else if (playerGuess &gt; numberToGuess) {
        cout &lt;&lt; "Your guess was too high, round " &lt;&lt; round &lt;&lt; "!" &lt;&lt; endl;
        printSeperator();
        lifesCounter--;
        cout &lt;&lt; "Number of Lives: " &lt;&lt; lifesCounter &lt;&lt; endl;
    }
    else {
        cout &lt;&lt; "Your guess was too low, round " &lt;&lt; round &lt;&lt; "!" &lt;&lt; endl;
        printSeperator();
        lifesCounter--;
        cout &lt;&lt; "Number of Lives: " &lt;&lt; lifesCounter &lt;&lt; endl;
    }
    return false;
}


bool playRounds(int&amp; lifesCounter, int upperRandomLimit) {
    int numberToGuess;
    for (int round = 1; round &lt; 3; round++) {
        numberToGuess = 1 + (rand() % upperRandomLimit);
        while (!guess(lifesCounter, numberToGuess, round, upperRandomLimit)) {
            if (lifesCounter == 0) {
                cout &lt;&lt; "Game Over! Actual Answer: " &lt;&lt; numberToGuess &lt;&lt; endl;
                return false;
            }
        }
    }
    return true;
}


int main() {
    srand(time(0));
    string playerNamer;
    int lifesCounter = 5;

    cout &lt;&lt; "Hello, what is your name? ";
    cin &gt;&gt; playerNamer;
    cout &lt;&lt; "Welcome to guess the number, " &lt;&lt; playerNamer &lt;&lt; "!" &lt;&lt; endl;
    printSeperator();
    cout &lt;&lt; "Number of lifes you have: " &lt;&lt; lifesCounter &lt;&lt; endl;

    if (!playRounds(lifesCounter, 10)) {
        return 0;
    }
    lifesCounter += 5;
    cout &lt;&lt; "You got more lifes! Now you have: " &lt;&lt; lifesCounter &lt;&lt; endl;
    cout &lt;&lt; "For the hard level, you have to guess a number from 15!" &lt;&lt; endl;
    playRounds(lifesCounter, 15);
    return 0;
}





P.S.: It's very hard to win when you have just 5 lifes for all 4 guesses. ¯\_(ツ)_/¯