#include <iostream>
We are asking the compiler to recognize and call into action the codes associated with iostream so allow the program to run after being compiled. It’s like a library of codes that we include in every C++ program so that the functions we create later can run.
int main()
We are calling a function here. In order for the program to work, you must call the function, which will work with integers.
std::cout << "You're on a secret mission, and you encounter a terminal";
std::cout << std::endl;
std::cout << "You need to enter the correct code to enter the next room...";
We are telling the terminal what to output. The terminal is what the player/user will see once we run the game. This is what gets output in the terminal after the code gets executed.
const int a = 4;
const int b = 3;
const int c = 2;
const int sum = a + b + c;
const int product = a * b * c;
Since our game is based on guessing numbers, we need to be able to tell the system what to do when numbers are input by the users. In this case, the user has no input option, and instead we are stating what numbers should be used in the code. By using ‘const’, we are saying that we do not want the values of these integer based variables to change.
std::cout << std::endl;
std::cout << sum << std::endl;
std::cout << product << std::endl;
After we declare our constant variables and assign values to them, we can use various operators to create sums, products, or dividends. Basically, this section is saying we will make a new line after each operator is executed. So for example, if we add the variables that were declared, the terminal will output the correct integer and put the terminal cursor at a new line beneath so that more output can be given.
return 0;
We are saying that once all the above code in the program runs, to stop the program from running again.