Explain our code so far in Triple X!

The Pre-processor loads in a library of existing code for us to use before we start writing any actual code.

The main function is the script that an operating is looking to run when a .exe is run. This function defines the order and conditions that expressions and functions should be run in.

Declaration Statement - Are statements that declare the value of a variable and are ended with a semi colon.

Expression statement - runs single commands

The preprocessor directive compiles a library of statements and code which we can then use in our program.

The main() function is necessary for the code to run, it’s where all our code executes.

Through expression statements we either give some output information to the user of the program or rather we simply just express something within the code using the statement followed by a semicolon.

We use declaration statements mostly to declare variables, to reserve certain memory locations for data we are about to store.

And finally, we use the return statement for the main function to return an integer (in our case 0) if the code executed properly.

Hello again,

Our preprocessor directive pulls from a library that has already been stated that our main function code needs to pull from.

We have a main function because that is the group of code that holds all of the functions that we want in order to execute the “thing” (for a lack of a better term) that we want.

A return statement set for 0 lets us know that nothing has gone awry.

The expression statements are what we want to be sent back to us after we execute the code, what we want it to say to us.
The declaration statements are the variables that we have assigned that perform operations (such as + and *) to let us know what the out come is thus far, 9 and 24.

Jib

It loads many functions to apply in the code.

The main function is the main code where the program runs, return statement serves to feedback no erros in the course.

The expression statement is printing in the program the text and the result of some functions written in declaration.

What does our preprocessor directive do?

  • this is a library for codes and we need to use this for use that codes inside of it

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

  • because every programs need that function for work and we must use it.
    +return is sending “0” information to start of execution at every execution, and it says everything is okay all is good :smiley:

Explain our expression and declaration statement that we have written so far, to summarise what our program is doing.
+we use expression statements for texts like menu info etc.
+we use declaration statements for declare any variable a number and use it for mathematic problems

preprocessor directive provides the library containing some functions that the program will need.
the main function is the start of the program . the return statement tells the main function to stop.
declaration statement is the introduction of new constants and variables into the program.
expression statement is everything else?

an expression statement is any statement ending with ;
i guess including declaration statements?

Preprocessor Directive: provided source code already existing

Main function: Where the program execution is started

Expression Statements: used for assignments or function calls could be used to display text or receive an input

Declaration Statements: declares variables with their value name an type

Return Statement: Used to exit the program

What does our preprocessor directive do?

It tells the compiler to include the built-in “iostream” library in this program.

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

In C++, a main function is required in every program. It allows us to actually run the program and gives us a starting point. The return statement of the main function acts as an exit code. When it returns 0, that means that everything has worked as it should.

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

So far could program simply prints a prompt, initializes three variables, initializes the product and sum of those variables, and then prints the sum and product.

Preproccessor directive imports a library of code.
Main function executes the program and returns 0.
Expression and Declaration statements prints the prompt, initializes variable and then prints some of those variables.

  1. Preprocessor Directive
  • Enable to include libraries or packages to our code. It allows us to pre-define what we want to do in our function.
  1. Main function
  • Is kind of workplace for our code and runs c++ code. It has arguments that enable to do things while other factors have been fulfilled
  1. Expression statements
  • Displays what we defined
  1. Declaration statement
  • Additional step in our code that enables us to add new things inside our main function.
  1. Expresion statements
  • It means that we can display things after we have declared variables.
  1. Return statement
  • If all those factors above are true then our function/code can be compiled.

What does our preprocessor directive do?
Loads the library iostream which contains necessary code for input and output

Why do we have a main function? What does it’s return statement do?
The main function is required for all C++ programs. The program will not compile without it. The return statement returns the value zero signifying the program ran without errors.

Explain our expression and declaration statement that we have written so far, to summarise what our program is doing.
The first set of expression statements explain the purpose of the program/game. The second set outputs the results.

1.#include <iostream> is a library to execute cout operations
2.main() its the code that will be execute
3. expression statements only print the text that the user need to see
4. declaration statements ais use to set up vartiable and use then in the code in the expression statement
5. return 0; to know everything is running as intended.

#include gives access to library to do cout operations.

main() creates a function that we can put code into.

Expression statements express something in your code.

Declaration statements declare something in your code.

Return statements return the compiler so that knows whether something is wrong.

What does our preprocessor directive do?

#include adds a header file to the beginning of our program. This header file declares all the functions in the iostream library. The external library gets linked to or program later in the compile process.

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

The main() function is the entry point to our program. All other functions are called from here. When the main() function ends so does our program. The main function has type “int” and so returns an int (0) to the OS when it ends with the “return 0;” statement.

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

Expressions are bits of code that do stuff. They end with a ;. e.g print text or variables to the screen, call other functions or carry out mathematical operations.
Declarations declare, initialize or assign variables, constants or functions etc. e.g “const int a = 5;” initializes a constant integer called ‘a’ and assigns the value ‘5’ to it.

What does our preprocessor directive do?

  • The preprocessor director directive through the #include header file loads in code from an outside library, in this case iostream, to give us access to use the source code for our codes to make sense.

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

  • The main function is what’s required for the rest of our code to work, and the backbone of sorts for all the operations within the program. Without the main function, the program simply would not run at all. Every C++ powered program needs the main function in order to operate.

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

  • The expression statements consist of information being translated to the player for gameplay and serves as a way to give context into what is going on, as well as printing out the final outcome of adding and multiplying our declaration statements.
  • The declaration statements take the integers we have input and calculates the resulting sum and product as its own separate integers, to be used to translate it back to the player later on through expression statements again.

What does our preprocessor directive do?

It pulls code in from a separate library of code for us to use so we don’t have to write code someone else has already written for us.

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

The main function is the function that our program looks for when it initially runs. Without the main function our program would not run. The return statement says that everything worked as expected with no errors.

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

Our expression statements are more user interface related, these are things a user will see when they play the game. The declaration statements are code used in the background to make our program do what we want it to do.

What does our preprocessor directive do?

I believe the preprocessor directive calls the extra code that allows for input to be read in the terminal and output to be output to the terminal.

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

The Main Function is required so the compiler knows where to look to compile the code contained within. The return statement returns the int 0 if it completes successfully.

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

Our expressions are outputting the story text, then we are clarifying our integers, preventing them from changing with const, doing our math, and then outputting them.
The Expression Statements contain outputs to the terminal

It allows the use of certain keywords that have been defined previously in our code. For example, we have #include <iostream> to allow me to use std::cout or std::endl and the compiler would know what those statements mean.

We have a main function because that is where the program executes and we need to have an integer value return since the main function is an integer function.

The return statement makes it so the main function gets a 0 returned and will throw 0 errors (that’s the way I picture it so it makes sense).

The declaration statements are statements where variables are declared; their name, their type, their value, and if they’re const.

The expression statements are statements where data is being manipulates, std::cout << sum; is using data from our declaration statement, const int sum = a + b + c;, and telling the computer to show the variable in the command prompt.

Hi,

Preprocessor directive. Instructs the compiler to go find the file in<> and open it.
main function is the part that the computer runs (everything in thr {})
The first few expression statements bbefore the variables are to print the intro of the game to the screen.
The Declaration statements are to create and assign variables to the program and in this case also do some manipulations like sum and product
The last Expression statements are to display the sum and product of the other 3 variables we have created.

Privacy & Terms