Explain our code so far in Triple X!

What does our preprocessor directive do?

It loads library before the code is even compiled

Why do we have a main function?

It’s like the skeleton of the code, without it the program won’t start at all

What does it’s return statement do?

It says if we wrote correctly our code. We’re stating that return = 0 so if it returns anything but 0 there’s clearly an error.

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

First we wrote some lines of text, then we’re declaring our variables(in this case they’re constants). Lastly we’re trying to write our values using the variable sum and product!

What does our preprocessor directive do?

It includes access to another library so we can use functions from that library. For this directive we are using functions that allow us to print to the console. It also allows us to get user information from the console.

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

The main function is what the executable runs. The return statement gives the computer feedback so the computer knows the function is finished. When it gives the computer the code 0 it knows it was successful.

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

The first expression is writing two sentences to the console. They are separated into a new line with the expression std::endl. The declarations are declaring new constant integer variables and initiating values to them. The second group of declarations are declaring variables that add the previous variables together and multiplies the previous variables together. The second group of expressions are printing those variables to the console.

The preprocessor directive instructs the compiler to copy the code from iostream into our program before compiling.

The main function is the primary working function of the code. This is the starting point of the code and will run in order all statements and functions that are called in the main function code.

The expression statements are expressing the code to the terminal as directed in the statement. The semicolon at the end of each expression make it an expression statement.

The declaration statements are initializing our variables, be them constant or not.

The preprocessor directive its including a library of reference code without having to write it.
The main function makes the program run
The return statement allows the program to determine if the code is working by returning a specific value to the coder. If code is wrong an error code will display
The expression statement is code followed by a semicolon and represents the part of the code that some action is taking place?
The declaration statement is code the defines specific parameters within the code.

The preprocessor directive allows us to call onto another library of code to borrow within in program that we are writing. We include this at the very beginning of the code so that when the code runs, it knows that we are using lines of code that have been borrowed from another source in the code library. The main function serves as the protocol for making our TripleX game work and where we write all of the code inside to make our game come alive. Without a main function, our game would not be able to run at all. The expression and declaration statements serve to build the visual structure of our game such as printing on screen messages to the player and then declaring variables that change over the course of game’s progression onto harder levels.

Preprocessor Director: Its taking a code library and having use have access in our code.

Main Function: Contains the meat of the program, and tells the compiler the way to read the code

Expression Statements: Showcase strings and outputs data to read

Declaration Statements: Where all values expressed are initialized and understood by the compiler.

Return statement: Returns 0 if code does not fail and is a fail safe if anything goes wrong in the code.

Preprocessor Directive: Allows code from other libraries to be included and read before the code is compiled.

Main Function: The main function is required by every program in order for the code to run.

Expression Statements: Expressions that end with a semicolon./

Declaration Statements: Statements where variables and values are declared.

Return Statement: Returns an integer, a return value of 0 means the code was run successfully, any other return value results in an error.

Preprocessor Directive
Imports data from elsewhere into your code. This is performed before your code starts.

Main Function
Runs your combined statements as one unit.

Expression Statements
Statements that do not set or declare variables. Ends in a semi-colon.

Declaration Statements
Statements that set or declare variables. Ends in a semi-colon.

Return Statements
Returns a status or value back to the computer. Ends in a semi-colon.

The preprocessor directive tells the compiler to add code written by someone else on top of our code.

Every program must have main function. It is what the computer looks for to begin running the program. The return statement in the case of our main function returns the integer 0 to let us know that there are no errors.

Expression statements are expressions and are ended with a semicolon. The expression statements so far are sending information and instructions to the console. They use the iostream we included to show strings and variables to the console and instructions on when to end a line.

Declaration statements declare variables. So fare we have used declaration statements to declare and assign constant integers to our three variables, to declare and initialize a variable with the sum of those numbers, and to declare and initialize an additional variable with the product of those three variables.

Oh damn. I seriously have no idea how to explain what the Preprocessor Directive is. I thinking it calls a bunch of rules and coding structures into place so that certain coding methods can work. As for the expression statements - well that would be when the code is “Expressed” ie printed out to the user in whatever form you coded in. The declaration statements are also self-explanatory to me in the sense that this is where you’d declare what certain variables would be. But I still have to learn the Preprocessor Directive and if anyone would care to explain it to me in more detail, then please feel free to help me. thanks

Preprocessor Directive is where the code is being taken from, in order to be attributed the roles we need; Main function is the point where the project/code begins; Expression statements is what we want to show as brute information; Declaration statements is what we want to implement as a task for the brute information; Return statement is the end of code.

Thank You!

Vlad.

  • The preprocessor directive gives instructions to the compiler to carry out before compilation.
  • The main function is essential in c++, it is the start of the program and the program wont build without it. If 0 is returned then we know the program is working properly.
  • Expression statements are expressions which finish with a semi colon.
  • Deceleration statements declare variables
  • Return statements return a value

.

Preprocessor Directive add libraries that allow us to use such things as std and cout.
Main Function: Contains the main body of the code. This will contain all the declaration expression, initiation expression and call to other functions.

Return statement is the the end of all code statement that tells the user that the code is working.

The expression and declaration statements are initiating variables, outputting strings and numbers.

The preprocessor directive includes code from another location before continuing, making it available to the current file.

The main function is required by C++ files, and runs when the compiled file is executed. The return statement signifies an error code, or no error if 0 (zero) is returned.

Expression statements do something, in this case output text using the cout function included in the std namespace. Declaration statements define and manipulate variables.

What does our preprocessor directive do?

The processor directive introduces a library into the code that contains a premade code that is already written to be used in the code that I will write.

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

The main function is to let the program know that it will start compiling and performing operations starting from the main(). There is a return statement since the main’s type is an integer and needs to return an integer type so we return 0 (an integer).

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

Our expression statements in the program simply output the operations of the declarative statements.

#include < io stream > is the name space used to access code that allows the terminal to understand what it needs to do when instructed to cout << string. without this it may not know that it needs to print the string in the terminal.

int main() is the main code function that calls in the game/program loop. its needed in c++ to run the code and nothing will happen without it. The return function states that once the main function is finished the code has ended. Perhaps there could be different returns depending on if the game has been won or lost?

Expression statements are used to tell the code what you want it to do. When the semicolon is used it is the end of the instruction and the next expression will be called i.e. 1+1; will output 2

statements are segments of code that you want to be able to declare before the expression takes place. expressions will included statements and statements can be controlled through variables. You can either hard code variables or you can customisable depending on their purpose.

1. prepocessor Directive
This part makes sure that we can acces certain “libaries” so that we can use the codes from it. If we don’t have acces to it, we can’t code what we want.

2. Main function
this is the main function. Everything within it will be ran once, unless we tell it to run it several times.

3. first Expression Statements
The expressions statement is an statement where it has an outcome. in this case the expression statement is where we say that whatever is in between the symbol "

4. Declaration Statement
in this part we declare something. like: the integer who we called ‘a’ holds a value of 4. the integer who we called ‘b’ holds a value of 3. So whatever we give value makes it an Declaration statement.

5. second Expression Statements
Here we express something once again that has an outcome. in this case it’s a string and a empty space between the lines.

6. Return Statement
this is the part that says that we are at the end of the line. Then it returns and checks for errors.

The Preprocessor directive serves as the header which indicates the libraries to be loaded with the program before compilation.

The Main function holds the outline of how the program will be run from start to end.

Expression statements are used to execute tasks within the program.

Declaration statements define the objects that the program can use such as variables

The Return statement returns an integer to indicate that the program has run successfully after the previous lines of code were processed without error.

It includes header files that declare library functions, operators etc that the compiler needs in order for us to use them in our program

Because it is the required entry point of any C++ program

Terminates the program by returning the value 0 (to indicate success) from the main function.

Our initial expression statements allow us to output descriptive text to the console followed by a series of variable declarations which are created to allow us to store and use integer (in this case) values within our program followed by more expression statements that display the various values held in the variables. In essence it allows to to declare and initialise with values a series of int variables and then perform arithmetic operations on those and store and display the results

the preprocessor directive inputs lines of code from another library to help our code run well,

the main function indicates where the program starts ,so as to be able to compile, the return statement allows the program exit without any errors

our expression codes are being used to write to the terminal and tell a story, our declaration codes are being used to input the value of variables so as to run some basic calculations

i think? :man_shrugging: :man_shrugging:

Privacy & Terms