TripleX Game Progress so far -IF/Else statements

#include <iostream>

int main()
{
    //print welcome messages to the terminal
    std::cout << "You are a 007 agent breaking into a secure server room...";
    std::cout << std::endl;
    std::cout << "Enter the correct codes to continue......" << std::endl;

    // Declare 3 number code
    const int CodeA = 4;
    const int CodeB = 3;
    const int CodeC = 2;

    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeProduct = CodeA * CodeB * CodeC;

    // Print CodeSum and CodeProduct to the terminal
    std::cout << std::endl;
    std::cout << "+ There are 3 numbers in the code" << std::endl;
    std::cout << "+ The codes add-up to:"  << CodeSum << std::endl;
    std::cout << "+ The codes multiply to give:" << CodeProduct << std::endl;

    int GuessA, GuessB, GuessC;
    std::cin >> GuessA;
    std::cin >> GuessB;
    std::cin >> GuessC;

    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProduct = GuessA * GuessB * GuessC;

    if (GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
        std::cout << "You just save UK and his royal Majesty the Queen!! God Save the Queen!!";
    }

    else
    {
        std::cout << "You lose!!";
    }

    
    return 0;
}

If win condition has met:
If win

If lose condition has met:
Iflose

I’m guessing you posted this in the wrong area. This doesn’t look like Unity code, more like c++ so I’d guess Unreal code?

1 Like

Haha… yeah I already fix it. Thanks for seeing it.

No worries. Good luck with Unreal.

1 Like

Privacy & Terms