Explain our code so far in Triple X!

What does our preprocessor directive do?

It tells the compiler to include the library code into our cpp file.

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

The main function is the entry point of our application. Our code starts executing from its beginning.
We have a “return 0” statement to let the compiler know at the end of execution that everything went as expected

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

Expression statements : Used to output information to the console.

Declaration statements : Used to create our variables.

The preprocessor directive include in our code, other peoples code, for the purpose to re-use them and facilitate the process.

The main function is the part of code that will be executed when we run the program.

The expression statement is where we execute some type of action(arithmetics, print in the console and may others).

While the Decalration Statement is where we assign values to our variables.

What does our preprocessor directive do?

The ‘#include’ preprocessor directive tells the compiler to copy and paste all the contents in the iostream header file into this .cpp file. This means we can access all the code within iostream to write strings to the console.

Why do we have a main function?

The main function is the entry point to the program - think of it as the root of the program where all other functions are called at runtime.

What does it’s return statement do?

When the main function returns 0 this exits the application. If any other number than 0 is returned then an error has occurred.

Declaration statements

  • Each line is declaring a variable with an associated type.
  • A type is required so that the compiler knows what values can be assigned to the variable and also how much space to reserve in memory for said variable.
  • The ‘const’ keyword prevents the variable from being assigned a different value after declaration. This makes your intentions clear that this variable is to be read only.

Expression statements

  • Quite simply, they are lines in code which end with a semi colon.
  • The semi colon tells the compiler that it has reached the end of the line since the compiler ignores whitespaces.
  • These expression statements in particular are accessing hard-coded strings and our calculated values to display to the user on the console.

Preprocessor Directive
imports a library that enables us to print and scan lines
Main Function
will run when we run the program after compiling with TripleX.exe
Expression Statements
Introduces the game to the player by printing lines about it
Declaration Statements
Declares all the needed variables for the game
Expression Statements
Prints the sum and multiplication variables
Return Statement
To let the compiler know that the function is over

The preprocessor directive, #include <iostream> is used to include the header file <iostream> so we can use functions from it. The first block of expression statements is used to output a group of text to introduce the game. The declaration statements are used to set variables to be used later on in the program. The second block of expression statements outputs the values of the variables that we have set. Finally, the return 0; makes sure that our program has run successfully.

Preprocessor Directive contains all instructions to the compiler.

Without the Main function, program can’t run it will throw an error. A return statement will return 0 if it doesn’t return 0 it means our program has an error.

1.In the expression statement, We Expressed text and result of sum and product as output.
2.In the Declaration statement, declared some integer values to find the sum and product of integers.

Preprocessor Directive:
An already pre-compiled code from another library that must start with #.

Main Function & Return Statement:
A necessary starting line of code that allows for your code to run. The Return Statement shows us whether or not there’s an error in our code by running through it.

Expression & Declaration Statements:
Essentially its the body of our program, it defines variables, giving value. The expression is expressing what we want our code to do and say.

if i didn’t understand something properly please correct me! i’ll keep moving forward in the videos so either way i think i’ll keep progressing!

What does our preprocessor directive do?

The Preprocessor directive links functions like cout & cin with our C++ programs.

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

Every C++ program must have one and only one main function. The Execution of Every C++ program begins with the main function. A C++ program cannot work without a main function.

The Return statement in this code returns 0,which tell the compiler that the code has been fully executed.

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

In this program our first set of expression statements are displaying some messages for the user, while the second set of expression statement are displaying the sum and product of our declared variables.
Our Declaration statement are used to declare constant variables to store integers and their sum and product in.

It tells the compiler to load a library (in this case “iostream”) prior to compiling our code.

Only the main function contains code that will be executed on runtime, thus we will have to declare it, else nothing will be executed. return simply returns 0 and ends the execution, except when there is an error.

  • First, we print out some Strings in lines / new lines.
  • Then, we declare some integers (a,b and c).
  • After that, we declare sum and product, each are additions / multiplications of our previous integers.
  • Now, we print out these integers.
  • At the end, we stop the execution by returning 0.

preprocessor: pastes iostream into our .cpp file
main function: entry point for program execution
first set of expression statements: print introductory messages to player
declaration statements: set up data (specifically, numbers) used by the game
final set of expression statements: print level-specific numbers to player
return statement: end program execution without errors

What does our preprocessor directive do?
Our preprocessor directive loads code from another library before our code is compiled

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

We have a main function because every program has it or it will not run. The return statement allows us to see if there are any errors while we ran it.

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

1.In the expression statement area we have some strings that give us our introduction text
2.The declaration statements are where our variables a, b and c are declared at their initial values
3. In the third section we expressed the sum and product of the variables
4. In the final section is the return statement. If the return statement returns anything else other than 0 then there is an error

What does our preprocessor directive do?

It’s including the iostream library which allows us to use cout

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

It’s the main function our code uses, the return statement of 0 means that the main function completed normally, any other number is an error.

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

The expression statements at the start are setting up the story and prompting the user for the codes.

The declaration statements are initializing the variables.

This is followed with more expression statements which are showing the sum and product of the variables.

Preprocessor directives includes any pre existing library that we will use/reference in our code,

Main function is a necessity for running our code, every computer requires one to process and run our code,

Expression statements are code that end with a semicolon and declaration statements declare something, variables in our case.

preprocessor directive (iostream) is a pre written librarymay be used for input and output

main function is where we write our block of code that needs to be executed

return statements may be returns 0 if there is no error in our code after compilation

expression statements is that the expression followed by an semicolon

declaration statements is that were our variables are declared and getting ready for use

I am not really sure, but i think it sets the minimun and maximum difficulty that progresses over time.

The preprocessor directive is a line of code that includes code from another library that provides instruction to the compiler before the code can be compiled.

the main function is in the code because when the program is being run, the main function is the first thing to be located and executed.

the return statement is used to end the program once everything has been executed

expression statements are statements that are followed by a semicolon.

declaration statements are used to declare variables that can be used in our programs. without these statements variables and constants can not be used in the program and values can not be assigned to variables if they are not declared first in the program

What does our preprocessor directive do?
It loads up a library that is already available in cpp. There are certain functions defined in cpp ( e.g. cout<<) and we can’t use them until the compiler doesn’t understand its reference. Through preprocessor directive compiler can understand that from where these methods are taken.

Why do we have a main function? What does it’s return statement do?
main function is the start point of the program. When compiler compiles the program it is the main function that is the point of execution.
return statement tells what this program will return when executed. (void means it returns nothing).

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

expression is basically a segment of code that when interpreted can be considered as one stand alone portion. It is distinguished by ‘;’ . declaration is that segment of code that tells the compiler (or interpreter) to store memory for the declared variables.

What does our preprocessor directive do?
The Preprocessor Directive gives us access to some already written code.

Why do we have a main function? What does it’s return statement do?
We have a Main Function to hold the code within the script, without it the code wouldn’t run.

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

  • Expression Statements tells the program what to do
  • Declaration Statements tells the program details
  • A preprocessor directive instructs our compiler to perform a specific task before the compilation of the program. For example in ‘# include’ we instruct compiler to include a specified library to our program before compilation of the program.
  • A main () function is the entry point of a program from where the execution of the program begins.
    The return statement tell the operating system about the successful termination of the program.
  • A expression statement are the statements in C++ program which ends with a semicolons ( ; ) . Declaration statements are used when we declare a variable.

Basically it tells our PC that there is a library that it needs to search for which contains some code in it. It will search for it first bc of the # in it.

main function is like its name says a main function. If we need to use for example one of our functions or something like that we have to use it there to make it work. return 0 tells us that everything is fine. If it would be some other value then it would mean that something is brokey.

we used cout to print out some text which has to be in between of " " (A.K.A quotation marks). It also can print out other things like our variables.
The endl simply ends our line and puts a new one below.
int is a type of a variable that can contain only INTEGERS in it. It stores data which we can use later on.
const makes our variable something constant, that means it cannot be changed and it tells other programmers that we don’t want anybody to change that value.

Privacy & Terms