Triple X if else

Hello,
Here is my code up to if-else.

#include <iostream>
using namespace std;

int main()
{
    cout << "You are a secret agent breaking into a server room..."<<endl; 
    cout << "Enter the correct code to continue..."<<endl;
    const int CodeA = 8;
    const int CodeB = 2;
    const int CodeC = 4;
    
    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeProduct = CodeA * CodeB * CodeC;
    cout << endl;
    cout << "+ There are three numbers in the code" << endl;
    cout << "+ The numbers add-up to " << CodeSum <<endl;
    cout << "+ The code Multiply to give " << CodeProduct << endl;
    
    int GuessA,GuessB,GuessC;
   
    cin >> GuessA;
    cin >> GuessB;
    cin >> GuessC;
    
    
    cout<<"You Entered: "<<GuessA<<GuessB<<GuessC << endl;
    
    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProduct = GuessA * GuessB * GuessC;
    
    if(GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
       cout <<"You Win"<<endl;
    }
    else
    {
        cout <<"You Lost"<<endl;
    }
    
    return 0;
}  

This is what I have now

type or paste code here
```#include <iostream>

int main()
{
    // Print welcome messages to the terminal
    std::cout << "You're a secret agent for the Canadian Security Intelligence Service (CSIS)" << std::endl;
    std::cout << "breaking into someone's secure cellphone to retrieve data" << std::endl << std::endl;
    std::cout << "Enter the correct code to continue...";

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

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

    // Print sum and product to the terminal
    std::cout << std::endl << 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 << "Congradulations, you cracked the code!";
    }
    
    else
    {
        std::cout << "Oh no, you have been found out and security in on the way. Run, get outta there!";
    }
    return 0;
}

Privacy & Terms