Explain our code so far in Triple X!

What does our preprocessor directive do?
This is an instruction to the compiler and tells this compiler how to run the code

Why do we have a main function? What does it’s return statement do?
The main function is where the code is stored and processed - without it, we cannot run the code. The return statement is to show the end of the program - the program has been run successfully

Explain our expression and declaration statement that we have written so far, to summarise what our program is doing.
Expression statements are used to provide visual information to the player (e.g. text, spaces/end lines, etc.) Whereas the declaration statements contain code and information which the expression statements can use to present to the viewer/player.

The preprocessor directive in this case allows an already established library of code to be included and added before anything else is compiled. It allows us to use code developed by other developers and programmers. It needs to be included at the start, before the compiler processes the code, so that it can understand the bits of code that we’ve used from this library.

We have a main function because in C++ this is the initial function that our OS will look for in order to execute. It holds the main body of information for our program. It’s return statement allows the the OS to recognize that the program has run successfully and can close. It will also signify an error if something other than the return value ( 0 in this case) is returned.

Our first body of expression statements instructs the program to print the text to the terminal as well as ending and starting new lines giving the text spacing.

Our declaration statements has given values and names to the variables that we are going to use.

The second body of expression statements instructs the programs to print the values of some of our variables.

If anyone notices me mixing up terminology please correct me as I’m new to a lot of the jargon.

Preprocessor Directive is what we use to take the code of a file, there are various libraries included by default on many IDEs and Text Editors.

The main function is what we use to start up everything our game needs.

Expression Statements basically expresses themselves, they are being used for inputting text into our game.

Declaration Statements declares variables into our game, which can be changed unless we prefix them with “const”

Return is used to tell the machine that the code ran correctly, otherwise another number will be shown.

Ok, I have been coding for 5 years but I will still do this!

The preprocessor directive is just like copying and pasting all code from another file into the beginning of our file, so our file can sue the functions from that.

The main function is the entering point of the entire program.

The return statement returns the output of a function. It is trivial in the main function but is extremely important for a common function.

The declaration statement declares a variable.

Honestly, I don’t really know how people named expression statement. Is every statement, which is not a declaration statement, an expression statement?

Preprocessor directive includes code from an external library

Main function lets the computer know that this is where the program begins

Return statement lets the compiler know if there is any error within the program, if there are none then the return statement runs successfully

Expression statements display text after the code is compiled

Declaration statements identify and assign values in code

The processor directive at the top of our code declares which code libraries we want to include when writing our code, in the case of TrippleX it is the iostream library that is referenced.

Next is the declaration of our function (main) which we declared to be of type int, normally a program will contain multiple functions called and executed under different circumstances during an applications run time.

Inside the body of the main function we start out with a few expression statements which tells the compiler to write out a number of lines to terminal in this case providing basic information to the user.

Beneath our first expression statements we find our declaration statements where we declare our variables and assign them values.

This section is followed by another block of expression statements that tell the compiler to write our sum and our product variables to the compiler below the instructions

Last we have our return statement in our case returning a 0. In any case where we do not use a function of type void we need to return a value that is of the same variable type as the function. This means that a function declared string want a line of text, a double function wants a double etc. You cannot return a value that is of another variable type than the function.

the preprocessor directive loads code from another file (at this point in time i do not think its doing anyting, but may be used later.

the main function is being used to tell the compiler where to start the code

The expression statement in the beginning is telling the terminal to print out the text we want to show up for our story.

The declaration statements are declaring a value to a, b, and c. they have also made it to where they cannot be changed from another line of code using const.

the next expression statement prints the sum and product of a, b, and c to the terminal.

The return statement is telling the terminal that the code is finished and closes the program with no errors

  1. The #include preprocessor directive simply includes a specific piece of code from the iostream library that the compiler runs before any other piece of the program.
  2. The main function allows the code to run, and is required for every program.
  3. Expression statements in the Triple X program allow text and formatting.
  4. Declaration statements create, input, and modify variables.
  5. The return statement is a tool to see if the code runs properly.

The preprocessor directive loads code from another source or library before the code is written.
The main function is the shell of the code that is being compiled and the return function checks the code for errors before compiling it. The expression statement tells the compiler what to compile such as text, while the declaration statement sets value.

int main: main function, has to be present, first function to execute
include<>: gives the directories path to the files.
std cout: sentences that tell the user whatever the coder wants to tell them, will not execute, only for communicating with players
int: declares a value for the compiler
const int : declares a non-changeble value for the compiler, cannot be changed further in the code
return: returns an int value to the compiler

The preprocessor directive indicates to the compiler which libraries to load into the final code.
The main function is the starting point end end point of the directives or instructions of our code.
The return statement of main tells the system that the program ran without errors.

:crazy_face:

#include : Is fetching a library of code that other programmers have made.

int main(): It is the funtion the operating system searches out to read. It is the corner stone of the code, without it, the code will not be built.

Expression Statements: They express something to us. A string of characters, that are followed by a semi colon, usually.

Declaration Statements: They declare something to us, such as variables.

Return 0: Tells the operating system that this line of code has come to an end. Any other value entered will result in an error. The value 0 will tell the system that the program ran accordingly, and no errors can be detected.

Its a database of code that we are applying to our own code.

We have a main function because it allows the program to run and is were most of the expression and declaration statements are located. The return statement allows the compiler to detect any errors and end the program with a return of 0 if there are no errors.

Our expression statements are outputting the text of our program and the declaration statement is establishing variables that will be the main tools for playing our game.

#include Preprocessor Directive is a library of other programmers code that allows us to use stuff like int, std, cout

The main() Function is in the file because every chunk of code for games needs one. without it the compiler will not even run
It is used to keep all the main bits of code that is needed

The expression statements are what are printing out to the player so they know what is going on game wise and through their input

The declaration statements are use to declare values to variables that will be used in the game

The return statement is there so the compiler knows nothing went wrong after every other bit of code has been executed. Not really sure
what return does

The preprocessor directive is there to include code that has already been written by someone else in our program without us having to write it all ourselves.

The main function is there to contain all the other functions and it is the driving force behind our program.

The expression statements affect what we see when the program runs.
The declaration statements state the variables which allow us to interact with the program and change its responses.

The return statement is there to let the compiler know what to do when it is done running the program.

Predecessor directive - a way which we can include code from another file(often it is library of code)
Main function - our main function is our main program. It should be where we place our code. Our compiler looks for the main function when it is compiling. The return statement in our main function indicates to the compiler if the function ran correctly or not. If it returns a 0, everything is good, any other number will cause an error.
Expression - are code statements that end with ;
Declaration - are statement that declare something into existence. It lets the compiler knows that this thing now exists. In our case, we have been declaring integer variables.

  1. Preprocessor Directive: This is for adding codes of others on top of our code.
  2. Main Function: This is the default function that compiler look to run first.
  3. Expression Statement: This for whenever we are writing a line of codes that is just nothing to be stored or nothing to be calculated or not even a comparison, their just doing something other than those things.
  4. Declaration Statement: This includes the codes that are declaring, defining and storing stuff on some variables.
  5. Return Statement: This is the part of code that returns some value to the operating system, by calling this in the main function we actually exit the code.

What does our preprocessor directive do?
I think it loads a bunch of libraries allowing us to add more complex code such as statements, rather than just integers.

Why do we have a main function? What does it’s return statement do?
We have a main function to tell the compiler that it is actually code & where to start.
return tells it when to finish.

Explain our expression and declaration statement that we have written so far, to summarise what our program is doing.
Expression is just expressing what we are telling it, as in a string.
Declaration is declaring a value that we can re use.

We use preprocessor directive to process other types of source code before compiling the script.
I assume main function is where the main code is stored and if it runs successfully (reaching the return statement at the bottom of the bracket) it will return 0.

Declaration statements is used to declare a variable which in return gets stored and can be used for expression statements. I think expression statements is to print what is shown.

What does our preprocessor directive do?

Before compilation, compiler finds preprocessor directives and replaces it. “#include” directive is replaced with content of header which is included.

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

Main() function contains all code which will be executed after compilation. Return statement gives some info to operating system. After return statement is reached, function’s work is done, and operating system can begin some after-execution work(cleaning memory etc.)

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

First, we put some strings into cout to see them in our terminal during execution. Then, we declare some constant variables. Finally, we put into cout sum and product variables to see them in our terminal.

Privacy & Terms