Explain our code so far in Triple X!

What does our preprocessor directive do?

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

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

8 Likes

Loads codes from another library prior to the written code being compiled.

Every program must include a int main() or it will not run. The return statement allows us to find out if there were any errors during runtime. If it returns the 0 that’s coded in, there were no errors. If it returns anything but 0, there was an error.

  1. First we expressed a few lines of text.
  2. Second we declared initial values of a, b, c, sum, and product.
  3. Third we expressed the values of sum and product.
  4. Finally we returned 0 to check for errors.
12 Likes

What does our preprocessor directive do?

It includes in our program some codes from another library before the code is compiled.

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

int main() is there, so the compiler knows where the program starts,if int main() wasn’t there the code would’t even compile. The return statement is there to exit without any errors. If it returns anything, then it means there was an error.

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

  • First, we print some lines of text.
  • Then, we declare variables (a,b,c,sum,product).
  • We print the sum and product values.
  • Finally we return 0, to indicate there was no errors.

#include
This line what it does is import the functions of the iostream library to be able to use them in our code.
int main () {…}, this is the function that will run our operative system.
Expression sentences allow us to print messages on the screen.
Declaration statements are used to create variables.
Return sentences are used to return a final value (integer) of the function main().
Sentences are lines of code ending in "; ".

Preprocessor directive statement includes an external block of code that is necessary for our program to execute.
Main function statement is the declaration of main function that is the heart of program execution, because when the program is executed the OS looks for main function to execute the full program.
Expression statements are included to output information on the screen to the user about what the program is about.
Declaration statements are required to declare variables that will be used in the program.
Return statement specifies whether the program executed successfully or not.

The preprocessor directive introduces code that other programmers have written that gives us access to tools like the standard namespace, including the “cout” command. It must be before any functions of the code, or else the program will not recognize many terms you attempt to write.

The main function is the principle function that allows the program to run on your operating system. The computer searches for this function in the program before all others. Its return statement provides the computer with an integer referring to the final state of the program, in this case 0.

Our expression statements, at the moment, are only writing things to the terminal so we can actually see them. Our declaration statements are creating and then immediately giving values to variables, as well as performing mathematical functions using those variables.

1 Like
  1. Preprocessor directive - calls for code that someone else has written, in this case the iostream. I am now purely guessing but ‘io’ in everyday electrical language can be an expression of ‘on and off’ just like binary 1/0. This or io could just simply stand for something else. Either way this is calling for something else to happen first that has been prewritten.

  2. Main Function - This is the area where we are writing our own code and in this case writing some speech in expression statements and defining some variables in declaration statements.
    In our case, this is building the start of our story and gameplay

  3. this is then returned/read/entered/transcribed into something the computer can read and opened to in our case the terminal.

@Liam “io” stands for “input” and “output”

2 Likes

Our preprocessor directive pulls in a database of other functions that we may want to use in our main function. We have a main function that is what is going to be compiled and lets the computer know what to compile. The return statement makes sure the program is running correctly and if it is anything other then 0 it will not compile. An expression statement are things that the code is telling the compiler. Where a declaration statement is letting the compiler know that we are identifying certain things in the code for it to remember.

What does our preprocessor directive do? It pulls programming code that others have created to help our program run. Much like a shortcut to coding.

Why do we have a main function? It is the main processing engine for our program.

What does it’s return statement do? It clears everything and returns a 0 value if everything is running correctly.

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

We have declared some integers and made them constant to protect them. Then we created sum and a product statements to output those values to the console.

  1. Our Preprocessor Directive #include <iostream> is allowing our program to use code that someone else has written in order to simplify what we are coding.
  2. Our main() function is where all of our code gets executed. C++ needs to have a main function in order to run our program.
  3. Our expression statements are being used to print text out to the player in our terminal, however not all expression statements will print text.
  4. Our declaration statements are being used to set up variables that our expression statements can then print out to the player.
  5. Our return 0; statement returns a 0 which lets our program know that everything is running as intended.
2 Likes

Preprocessor directive contains lines of code from a pre-made library of code to be used in our code which we are making.
Main function is the what the program needs to start and signal that this is a program.
The return function signals that this is the end of the program.
Expression statements are text which is displayed after the code is complied
Decelaration statements assign values to symbols

I think this is correct, hopefully near to correct

What does our preprocessor directive do?
In our case we import from a libary that allows us to use the terminal to show our code.

Why do we have a main function? What does it’s return statement do?
Every program need the main function, without the main it can’t run. The main function can only exist once in our project file. return 0 gives 0 back, that means our program runs perfect and throws no errors.

Explain our expression and declaration statement that we have written so far, to summarise what our program is doing.
We write the datatyp and declare the name of our variable, then we initialize and print it on our terminal.

The preprocessor directive loads in a code library with vital methods in namespaces that give this program its main functionality.

We have a main function to indicate the starting point of the cpp application. Its return statement is used as an exit status for the program.

Our expression statements print out to the console some introductory text that gives a brief intro to the triple X game and the sum and products of the values of the integer variables that have been declared. The declaration statement declares the values of the integer variables a, b, c, sum, and product.

What does our preprocessor directive do?

A preprocessor directive lets the compiler know that some task should be performed on this file before it is compiled. For our directive we are telling the compiler that it must “include” or load in the library of code called iostream before it can continue with the rest.

Why do we have a main function?

In C Style code the main function serves as a standard starting location for any code. When the computer tries to run the program it will search the code for a main function and begin code execution there.

What does it’s return statement do?

In any C styled code that does not have some other termination condition the code must always return from main. When the operating system has run the code it wants to know if it was successful “0” or failed “anything else”. If the code stops executing but the Operating System has not received a zero in return from the code, it will assume something has gone wrong and provide an error.

What’s this program doing in summary?

  1. It makes use of iostream to print some lines of text to the console.
  2. It declares variables for a, b, c and initialises them to some values then declares sum and product and initialises them to some operations of a, b and c.
  3. Again makes use of iostream to print our variables sum and product to the console.
  4. Finally, like all good C styled programs it finishes and returns a 0 so we know everything went well.

So far my understanding is pretty vague but, a preprocessor directive seems to allow other programs to access our program. The main function starts the program. The expressions tell our computer to run base processes. The declarations are defining terms. Return tells the computer to return to what it was doing before it ran the program.

I think it “borrows” basic terms or maybe systems that are essential to create a code, we do this probably so we don’t have to create this sort of thing ourselves.

I think the main function is what is where the main functions of your code colide, if there is a “main” probably there is a “secondary”, probably the main is where you organize the code that defines the program’s whole function and the secondary functions will only facilitate the work of the main. i think return statement makes the program go back to any certain line of code, probably as the one we use is “0” the program stops.

expression is probably the way the program interacts with the user in various ways(in the triplex we tell the player the game’s story), and the declaration defines values or rules that the program will use whenever a certain term is refered to in other lines.

What does our preprocessor directive do?
It loads some libraries before the compiler compile the program.
Why do we have a main function? What does it’s return statement do?
In order to run our c++ class we should have the main method its the entry point of our class.
Explain our expression and declaration statement that we have written so far, to summaries what our program is doing.
Every expression that ends with “;” is expression statement.
Expression statements allow us to print something on the screen.
Declaration statements allow us to declare and initialize variables.
Return Statement?
In order to know our program docent have any error and compile correctly it returns 0 otherwise the errors will occurs.

The preprocessor directive calls code from another header file / directive before it even begins to read the code written.

A main function is where all code is called from in C++. We have a main function so we can print code out to the terminal.

A return statement returns the code to 0 to exit the code.

Our declaration statements are declaring variables for the program then in our expression statements we express strings or the variables we declared in our declaration statements.

Our code is taking the variables 4, 3, and 2 and then reproducing it in either code sum or code product.

  1. Preprocessor directive is used to include a library and instruct the compiler to copy the contents the head file into your code before compiling rest of your code.

2a) The reason, we have main function, is because every C++ program requires main function and the program will not build without it. The entry point of the C++ program, pass arguments into the function, and makes holds the functions body which Expression & Declaration statements exist.
2) The point of the return statement is an exit status to the operating systems.

  1. The expression statement are lines of code within a functions body that end with a semi-colon, which ends a statement. The declaration statement are lines that we declare as a variable or something; such as using int or const int.
    3)The expression statements is what is be display to the user; while declaration statement is whats meant to be recognize by the system.

Privacy & Terms