Explain our code so far in Triple X!

What does our preprocessor directive do?

It tells the compiler to insert the code stored in the header file <iostream> this allows us to use the functions and variables declared in this header such as std::cout or std::endl

Why do we have a main function? What does it’s return value do?

Because otherwise our C++ program would have no steering function for the operation system to execute. The return value is the code the program sends to the OS that tells it if the process was successful <=> return 0; or unsuccessful <=> return 1;

Explain our expression and declaration statement that we have written so far, to summarise what our program is doing.

The first three non-white-space lines in our main function are expression statements that output the outline of our story. These are followed by five declarative statements where we define a set of constant variables and their values. And lastly, the two lines above the return statement are expression statements again that output the values of the sum and product variables declared above.

The Preprocessor Directive is code that tells the compiler to load in data and information from a pre-existing library allowing it to use C++ code

The main() function is an important part to C++ program because it tells the compiler all the important information that it is looking for in the program’s operation. The main() function also needs a return statement so that it tell the compiler when to exit the function, in this case, return 0 to exit the function. The main() must return 0 or else it’ll report an error which needs fixing.

The first three expression statements tell the compiler to print out text strings to the console using the std:: cout namespaces that are allowed by the pre-processor directive.
The declaration statements tell the compiler to store information that we can assign or change throughout the program, such as variables, provided they are not called after the operation is finished. Lastly return 0 serves as a the return statement which closes the main() function by returning the value 0, showing there are no errors.

Preprocessor Directive: it’s loading the libraries we need for using functions such as std::cout, std::endl, etc.

Declaration Statements: like the name says, they are declaring (creating) the variables we need and assigning them a value (in this case), these variables can only be used after they are declared.

Expression Statements: these statements execute code the code we tell it to run.

Return Statements: they are providing a feedback code as a result of using the function. As our main function expects an int we are returning an int of value 0.

What does our preprocessor directive do?
The preprocessor directive brings in code written by others to accomplish certain tasks. In this case, to output strings to the terminal window.

Why do we have a main function? What does it’s return statement do?
Every C++ program is required to have a main function. Beyond that, main() functions as the place to control the flow of the program.
The return statement tells the computer that there are no errors after running the program successfully.

Explain our expression and declaration statement that we have written so far, to summarise what our program is doing.
Our expression statements so far display an initial message to the user on the terminal.
The declaration statements declare and initialize a total of 5 variables. Two of the declaration statements initialize their variables by using maths.

  • Preproccesor directive imports the library,with wich we will work in our project before compiling.

  • Main function indicates the program first to look there and also shows the reader of the code the heart of the code

  • Expression statments are parts of the code that fill up the content of our code,creates variables with wich we will work,ect.

  • Declarative statments make some count or change for us,which most usually is used later as reference(in output or just in another declarative/expression)

  • Return statments return the value of the function.Normally,return will give back the result of something doing inside the function,but we have ‘main()’ here,so it just returns 0 aka False and shuts down the program.

Preproccessor directive - it is used to include all the operations within itself.
main function - entry point of compiler where the execution of code starts.
Explanation of our Code - we are a secret agent :stuck_out_tongue_winking_eye: trying to get the three numbers satisfying the conditions.

What does our preprocessor directive do?

It includes new libraries to our code, so computer will now know what we want it to do.

Why do we have a main function? What does it’s return statement do?

The main function is to start our program. Without it the whole program would has no sense. You put there everything you want your program to do (except other functions if you want your program to be clear - but you have to mention them in main function).

Return statement means that your program is working without problems and errors.

Explain our expression and declaration statement that we have written so far, to summarise what our program is doing.

  1. Explain statement is when you change a variable which was declared before or when you want your program to show something on the screen.

  2. Declaration statement is when you declare something. For example an integer.


The Main Function is needed to run any program in c++, it is the first thing c++ will look for when executed in the terminal.

Expression Statements are lines of code used to display information to the player, and are identified by ending with a semicolon.

Deceleration Statements contain your variables and arithmetic operators.

The Return Statement is used to end and exit the program, and the number returned must be 0 for it to be executed without error.```

Preprocessor Directives: This is what you use when you need to include code/coding shortcuts from outside the main “dictionary”. It adds different coding libraries so that the computer will understand the terminology you’re using.

Main Functions: This starts the whole program and without it you would just have a blank terminal or even an error statement. It’s the heart of the code, and where the computer would look first to give you an output. These are required.

Expression Statements: Our expression statements in this case are probably the meat of the code. They are the lines that send input to the computer and tell it to do things, whether you see that in the output or not. (e.g. “MyVariable = 12;” is an expression statement just like “std::cout << MyVariable;” is)

Declaration Statements: These are mainly used as reference statements. They can declare and initialize things such as variables. (e.g. “MyVariable = 7;”)

Return Statements: You should never actually see this come up in your output. If it does, it means you have a coding error and you need to tweak your code. It’s basically a safeguard.

preprocessor directive instructs the compiler to add the library before compiling. We have the main function because every c++ program requires it and it is an entry point to the program. The return function tells the compiler any returning number other than zero will result in an error it is also used to exit the program. The expression statement is an expression that ends in a semicolon and a declaration statement declares something and in our case, it is the variables.

  1. What does our preprocessor directive do?
    A. It directs to a header file and loads all the functions of that class so we can use it

  2. Why do we have a main function? What does it’s return statement do?
    A. Main function will run all the code beneth. Return lets u know if your code was run sucessfully or not.

  3. Explain our expression and declaration statement that we have written so far, to summarise what our program is doing.
    A. Declaration is where we declare our variables and expression is where we run a function.

  4. We used expresion to print a string.

  5. We declared few int variables such as a, b, c. We also declared the sum and the product of these variables by using * , +.

  6. we used a method to print the values of these variables

  7. we put the word const infront of the variabls to protect them from changing their value.

The preprocessor directive fetches codes from an online library, so we can use stuff like cout and cin.
The main function is where c++ starts running the code.
Expression statements are things that are being displayed to the user.
Declaration statements are variables that are being assigned some values.
The return statement is making sure that the code has run in its entirety.

WHAT DOES OUR PREPROCESSOR DIRECTIVE DO?

  • our preprocessor directive includes specific library of functions in our code so we can use it, and don’t have to write everything from the scratch.

WHY DO WE HAVE A MAIN FUNCTION? WHAT DOES THE IT’S RETURN STATEMENT DO?

  • Our main function executes our program and it is used as a body. It’s return statement tells the compiler that the program has run as it should, cause if there is some problem with the code so far, the program won’t reach end statement?

EXPLAIN OUR EXPRESSION AND DECLARATION STATEMENT THAT WE HAVE WRITTEN SO FAR, TO SUMMARISE WHAT OUR PROGRAM IS DOING.

  • With the expressons, we are expressing something that is just there or is stored somewhere, and with the declaration, we are reserving and storing something in computer memory to be called out later.

The preprocessor directive imports a library that allows us to use functions which prints stuff on the terminal.

All programs have a main function and is the first function the program checks when compiling, since it is a function, it expects to return a value, and the value 0 is used for saying the the program ran without issues.

The expression statements are used to give instructions to the user on how to play the game and deliver hints on regarding what the numbers are.

The declaration statements hold the values of the random numbers and the values of the hints that are given.

In my opinion;
The Preprocessor Directive : It is allowing us to use libraries by importing them
Main Function : It is like the skeleton of the human body, it creates environment for us to use our code in it.
Expression Statements : We can express what we are doing in our codes with the help of expression statements. We can see the “picture” of our codes in terminal, or in the our finished program by the help of expression statements.
Declaration Statements : We can declare what we are doing in our codes, we can declare and decide the details with the declaration statements.
Return Value : Since The main function is a function, it has a return value. If return value is zero, we can understand that our code is running with no issue.

So think about a painting, preprocessor directive is the shop which we can obtain materials from it for our painting, main function is the frame of our painting, expression statements is our brush movements, suns, trees and etc. of our painting, and declaration statements is the types of paints, colors we choose, brush sizes etc.

The pre-processor directive does?

loads a certain library of code within your code which saves you time making up the code yourself.

Why do we have a main function? What does it’s return statement do?

its the start of the code without it wont run when its complied. The return statement sends a 0 if the code had no errors but if it did you would get some sort of error.

Explain our expression and declaration statement that we have written so far, to summarise what our program is doing.

we give our variables a value
and we declare the variables a, b, c with sum and product and return 0 to find any errors.

The main function is the core of the program. This function will call all the other one we need our program to work. The return statement is here to tell the computer if the program ended correctly or not. This is used to get something like error code, I guess.
The preprocessor directive is here to tell the compiler to include external code we’ll need for our program. This one is used to handle our inputs.
Declaration statements are used to get memory space were we can stock our variables, const means that those ones are not mean to be changed later. Expression statements finally are here to print messages to the player and get the input so we can compare them to our variables.

#include is loading codes from another library
Main function is need to compile the code and return is to say the function has no errors
expression statements are statement to give lines of text
while declared statements saying what things are.
our program is giving us a scenario while adding and multiplying integers to give us sum and products

Preprocessor Directive: loads the necessary tools/library for the program to run and adds it to the code for compiling. in this case ‘iostream’

int main() Function: The main function of the program, it begins and ends here.

Return Statement: Return 0, an integer, thus when this happens the program works and is O.K to run. I find this interesting since why not return 1, or 2. possibly has to do with the computer language of 1’s and 0’s.

Expression Statements: followed by a semicolon, expression statements are different kinds of expressions for the computer to read, either to print out or otherwise.

Declaration Statements: Declares any type of input necessary for the program to run according to your liking. They must be stated and viewed by the compiler to read as a certain type of information. Thus we include the int or const int.

My Question is: Can a declaration statement be considered an expression-declaration statement, since in the video we showed one example of “cout”, understandably it is an expression statement since followed by semi colon, and also prints to the terminal although not necessarily. But the “myVariable = 5;” is considered an expression statement as well, but of coarse it was declared at the start as “int myVariable;” which is an aspect of declaration.

Privacy & Terms