TripleX dosn't work :/

Hi everyone, I’m stuck at section 2, lesson 27-28. I’ve written all the code bit by bit how it’s done on the videos and somehow my program doesn’t run. Compiler doesn’t show any errors but when I try to run the program, nothing happens. I’m not sure, if I screw up something in my code that I just don’t see or is it the case of my laptop :frowning:

                // "preprocessor directive includes a pre-made library for your code to use"
#include<iostream>

void PrintIntroduction(int Difficulty)
{
               // "expression statements print out the text onto the screen"
    std::cout << "\n\nLevel " << Difficulty;
    std::cout << "\n\nThe nuclear warhead is on its course to hit Rosegaarden.\n";
    std::cout << "If you manage to hack the warheads, you can activate their self-destruct mode.\n";
    std::cout << "Millions of people depend on you, so... No pressure, ok?\n";
    std::cout << std::endl;
}
                // "calls out the PlayGame function"
bool PlayGame(int Difficulty)
{
                // "calls out the PrintIntroduction function within our PlayGame function"
    PrintIntroduction(Difficulty);

                // "declaration statements let you insert variables into your program"
    const int FirstNumber = 4;
    const int SecondNumber = 3;
    const int ThirdNumber = 2;

    const int CodeSum = FirstNumber + SecondNumber + ThirdNumber;
    const int CodeMultiplication = FirstNumber * SecondNumber * ThirdNumber;

                // "prints out hints about the code required"
    std::cout << "There are 3 numbers in the code.\n";
    std::cout << "The sum of the numbers is:\n";
    std::cout << CodeSum << std::endl;
    std::cout << "If you multiply the numbers, you'll get:\n";
    std::cout << CodeMultiplication << std::endl;
    std::cout << "\nPlease insert the numbers in order from the highest to the lowest.\n";
    std::cout << std::endl;

                // "sets the variables for player's input"
    int FirstGuess;
    int SecondGuess;
    int ThirdGuess;

                // "asks for player's input"
    std::cin >> FirstGuess >> SecondGuess >> ThirdGuess;
    std::cout << std::endl;

    int GuessSum = FirstGuess + SecondGuess + ThirdGuess;
    int GuessMultiplication = FirstGuess * SecondGuess * ThirdGuess;

                // "performs an if statement to check if the information from the input is true"
                // "comes up with a different dialogue if the input is true or false"
    if (GuessSum == CodeSum && GuessMultiplication == CodeMultiplication)
    {
        std::cout << "You managed to cancel the strike. Congratulations!\n";

                // "creates an exit point out of the PlayGame function and returns a true value"
        return true;
    }
    else
    {
        std::cout << "Inserting the wrong code caused more warheads to be launched. The end is nigh...\n";

                // "creates an exit point out of the PlayGame function and returns a false value"
        return false;
    }
}

                // "main function makes the program be recognised by the operating system"
int main()
{
                // "performs a loop for as long as while statement is true"
        int LevelDifficulty = 1;
        
        while (true);
        {
        
        bool bLevelComplete = PlayGame(LevelDifficulty);
        std::cin.clear();
        std::cin.ignore();

        if (bLevelComplete)
        {
            ++LevelDifficulty;
        }
        }

                // "return 0 closes the program after it finished running"
    return 0;
}

/*
A
multi-line
comment.
*/

At the end off while(true) there doesn’t need to be a ;

1 Like

Gush, how could I not notice this?? :stuck_out_tongue: Thank you very much for your help, I’m really sorry it was necessary with something so simple ;_______;

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms