Explain our code so far in Triple X!

Preprocessor directive - connects our code to the corresponding c++ library
Main Function - the block which contains the main function performing in the code. I assume everything we’ll have in our game will be included in this section
Declaration statement - lines where we declare our values and I believe these values will be a correct answer for the player.
Expression Statement - the rows which make our code visible in the Terminal
Return Statement - not sure so far, but I believe it returnes “0” in case of incorrect answer

Okay, here goes…

Directs the compiler to load specified header files containing Namespaces and code which is used inside the main function.

This is always the first function the computer will read. If there is no main function, the programme will not run.

Gives the function and exit point and returns the number 0 if the code has executed correctly. If the function returns any other value, there there is an error within the codes.

  1. Print out text to terminal.
  2. Declaring constant variables.
  3. Calculating constant variables.
  4. Print out some of these variables to terminal.

The preprocessor statement makes code in other libraries available to you within the program you are writing. Without the #include <iostream> line, you wouldn’t be able to use cout & cin.

Every program has a main function so that when you run it from the command line or within a GUI by say double-clicking on it, the compiled code knows to start within main. The return statement is an error check; most programs return 0 if they ran successfully, and something other than 0 if they failed (in other words, you didn’t get to the end of the program where the return 0 statement is).

Expression statements are to provide information to the user in the form of printed text. The declaration statements are needed to be able to use the various variables in our program, whether to print them, modify them, or use them for some other function within the program.

preprocessor directive is used to to attach the code made by others before our written code.
main function shows where our code start to compiler if we don’t include main function code will not compile.
return statement implies program is ended exit from the program .
expression statement are those which give some output in the program /express some thing.
declaration statement is used to declare something in the code.

Preprocessor Directive imports code from the designated file and allows us to use the commands/functions in that file.

Main Function the function that the compiler looks for while running the program. Executes the code within the brackets.

Expression Statements an expression that is followed by a ;.

Declaration Statements a statement that declares something. (const int digitOne = 2)

Return Statement returns something from the code within to the function.

Loads code from another library

We have a main function because every compiler needs a main function in order to work. It’s return statement tells the computer the main function has served its purpose and can exit the function.

Expression Statements are ended with a ; that have expression or purpose
Declaration Statements are declaring new variables
Return Statements returns something from the code inside the function and exits the function with that value.

preprocessor directive loads code from another library.

every compiler needs a man function to work.
expression statements ends with a ;
declaration statements a statement that declares a new variables.

return statements returns something from inside the code.

Preprocessor DIrective : instructions to complier, what library to include before compiling additional code below Main Function.
Main Function : bulk of programmed code, required to begin the program.
Return Statement : defines end of code, confirms no errors occurred, program runs successfully.
Expression Statement : print to terminal but must occur with a semicolon (in our game we have written a greeting for the user).
Declaration Statement : defines or “declares” variables, what they are and what they do (in our game we have defined a, b, and c, and their sum and product).

In summary, we have begun our code with our compiler library, welcomed the user, defined variables that will impact the user soon, and successfully run our program! =D

What does our preprocessor directive do?

Loads a library, a collection of preprogrammed statements and vocabulary, for us to use, prior to our written code.

Why do we have a main function? What does its return statement do?

Every function must include a main() as the body of its code. The return statement allows us to check for errors during runtime.

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

Our program starts by printing two strings to text to the terminal sequentially, followed by establishing the constant integers a, b, c, sum, and product. It then displays the sum integer and product integer (which are the sum totals of variables a/b/c and product of above, respectfully). Finally, we return 0 to check for errors.

main function what I had believed it to be yesterday was a function that gives the computer a range from a-z or 0-9.
Also im discord as Mula wouldn’t allow me to merge both accounts thank you

Our preprocessor directive imports code from another library so that our code can run.

Our main function is our central function that ensures our code can run, and its return statement returns a value to the code to ensure it is working properly.

I think that expression statements are expressions followed by a semicolon and are expressed in the terminal, but I’m not 100% certain.

Declaration statements declare something, in this case they are declaring and assigning value to our variables.

Preprocessor Directive- instruction for compiler
Main Function() without it c++ won’t run -necessity
Expression Statement values and sentences are expressed
Declaration statement declares and assigns value to variables
Return statementreturns to check for errors 0 = good 1 = error

The preprocessor directive is external code that we want to implement in our own code. We use #include statements to access the library of code and a header file to access the specific code we want to use and this also allows the compiler to include and run it in our program.

the main function () is a standard and entry-point in C++ that allows us to successfully compile code written in the language. This is what the operating system will look for in our code to compile it successfully. Without it, the program will not run and an error will appear.

Expression statements - These are lines of code that end with a semicolon. They are not necessarily statements that will be printed to terminal; and are also not inclusive to declaration statements although they too, end with a semicolon.

Declaration statements - These are lines of code that contain variables, assignment operators, and values. It is where variables are declared and initialized and the statements end with a semi-colon. Declaration statements are a way to create space/memory for it.

Return statement - Part of the function body of main (), this is what the operating system looks during compilation to check for an error. Namely, if “return 0;” is not detected by the operating system that means there is an error.

I hope these are correct! Please do clarify if I’m wrong. Thank you

The preprocessor directive is inserting a library that are written by other people into our file

The main function is where all the things so far have been written be run without the main function the program will not run, and for the return statement its mean that the program has run successfully and we are exiting the program

the expression statement is where all the statement or text that we want to display it in our compiler, whereas the declaration statement is where all the variables were written to run in the expression statement

The preprocessor directive lets us use the tools from the iostream header file such as std::cout, our main() function holds the main body of all of our code (i.e all of our expressions, declaration statements, ect.), as well as allowing our C++ program to actually run, and our return statement lets the program safely end without error once it reaches the end of our code.

Our expressions allow our program to print out the given strings to the terminal/screen when they are called, and our declaration statements assign number values to our variables a, b, and c, and then total them together in our next variables sum, and product.

Our Preprocesser directive includes a c++ library into our c++ code.
We have the main function because its the only function for our code to work properley.
The return statement tells the computer to exit the program.

Our Preprocessor directive calls and allows the rest of the code to access a Library of functions created by another programmer.
Our Main Function is our way to start a program which will be compiled and running as per our instructions. Without making int main(), no other function would be starting.
Our Expression statements reflects what we want the code to show back to the player/user.
Our Declaration statements allow us to include variables into the function, making it easier to show ints/floats/strings/… that can even be varying throughout the function.
Our Return statement indicates that we have finished running our code.

I’ve had to google this to get a further understanding but from what ive found its including a form of language or set of rules/definitions, we’re using “cout” to make our game visable on the screen.

From what I’ve gathered so far the main function is used by the compiler as the start point of the code, and once finished the return statement sends errors back if any have been found. If no errors are found then the compiler gives us a working .exe?? this is the picture in my head so far anyway.

Our expression statements are what we are asking the program to display on the screen, and our decleration statements are information or rules we are telling our program to abide by.

One preprocessor directive can be " #include ", which allows us to use other people’s codes, and it is followed by the header file of that specific code, for example, " ".

The main function is mandatory for any code we are writing. It is where the main processes of the code happen and where they finish. We also have the return statement in it, which tells the computer that the code operation was a succes, if it returns 0. If not, it wasn’t a succes.

As an expression statement, we have the “std::cout << etc…” which are going to be shown on the user’s screen and give him some intel about the problem.
As a declaration statement, we have the “const int a = etc” which does exactly what the name says it does : we declare a variable that is integer if we write “int” and if we write “const” that variable is going to be set up to constant, meaning it’s not subject to change in further actions. So, in our game we are declaring the variables that are going to help the user with the problem.
And in the end, we have another expression statements that are going to show on the user’s screen the values of the variables calculated, either if its a sum or a product.

the preprocessor directive tells the compiler to include the iostream library. This library includes functions and objects for input and output.

All c programs include a main function it is the heart of our program. The return statement in this case lets us know when the program completes without errors.

Our Expression and Declaration statements are first outputting txt to the console to tell the user what’s going on, Then assigning values to variables a, b, and c. Then calculating the sum and product of a, b and c, Then outputting the values of the sum and product variables.

Privacy & Terms