What I think each part of a piece of code does

What I think each part of the code does in my own words:

  • Preprocessor Directive: It include a file of code into your code that you need.
  • Main Function: This is the part of code where the compiler knows that this is the place where code needs to be ‘run’/output(something of the sort :smiley:
  • Expression Statement: These are statements that output/process something.
  • Declaration Statement: These are statements that declare variables, functions, arrays, pointers, and constants.
  • Return Statement: Since the main function is declared with an integer, and number must be returned, which can confirm that there are no syntax errors.

What do you guys think of my explanations? How accurate are they?

5 Likes

I think its close to accurate!

Preprocessor Directive : This includes additional libraries of C++ functions that we can use in our program. I believe the iostream would have something to do with interacting with the operating system.

Main Function: This is the function that c++ executes to run the application. Anything outside main will not be run unless it is referenced by main or called by something that is referenced in main.

Expression Statements: These are actions to be taken by c++ such as writing output to the console.

Decoration Statements: These statements create buckets (variables or constants) to store information in and set the information to be stored.

Return Statement: This provides output from the function.

2 Likes

Preprocessor Directive: All the files we want to include must be a part of this. They must be copied to our program before anything else hence, being always at the top of the file.

Main Function: The function executed first. The brain of our program. The map to find the lost treasure. This function calls all the other functions we write (or at least the most important ones). It is the general, where all the other functions report to.

Expression Statemens: They usually include input and output. Expressions, can also be variable assignments, such as a = 5; (provided that we declared “a” earlier). In this case, they represent input and output.

Declaration Statements: The name pretty much gives the answer. Commands that include the declaration, the creation of new variables.

Return Statement: They return something to the parent function. This “something” could be a variable, an object, anything that can be passed.

Preprocessor Directive I’m assuming it’s like file that we need for my code
Main Function Everything under this c++ will process. I’m assuming it’s the main process.
Expression Statements These are what will be inputed into c++
Declaration Statements These are the rules you give variables.
Return Statement This is what ends everything in the main function and outputs it.

preprocessor directive- it is insisting to the compiler to read a file
main function - some c++ code includes in it
expression statement - it shows us like … game over or winner winner chicken dinner.
declaration statement - this is the working people inside a game
return function - I don’t know what it does…:cold_sweat::cold_sweat::cold_sweat::cold_sweat:

Preprocessor Directive: code/file that is loaded and used before the beginning of your code

Main Function: is the body of the code

Expression Statements: setting variables and making sure everything is defined

Declaration Statements: is the action of the code what it is doing in terms of commands.

Return Statement: goes back to a specified line in the code and starts the code over from that point.

Preprocessor Directive: This instructs the compiler to look for files outside of the code.

Main Function: This is the body of our code. signifies the beginning and the end of our code with the use of {}.

Expression Statement: This tells C++ what to do with the results of our code.

Declaration Statement: This is where a value is given/assigned to variables.

Return Statement: Output of our code. Ends the code and returns something from previous statements (sum, product, string…) The end result of our code.

Preprocessor Directive is used to refer an external library that can then be used in our code. When compiling, the content of the library is copied at the beginning of our file.

Main Function is the entry point of our program. The body of this function includes everything between the curly braces following the function declaration.

Declaration Statements are when a value is assigned to a variable/constant.

Expression Statements are the action made on/using the previously declared variables/constants.

Return Statement indicates the end point of the function and return it’s result.

Preprocessor Directive is the file that will be used while creating your code.

Main function is the first set of code that will be used to create this text we see in our terminal.

Expression statements are used to define a variable which can eventually be used to declare a statement

Declaration statement is used to announce in code to execute those variables and make it show in our terminal.
Return statement makes the code RETURN back to the beginning. And the end of the code

The preprocessor directive pulls code from a library that exists already, in the case of Triple x it is pulling from the Iostream library. It will use the #include to identify the library you wish to pull code from. The main function is the main part of the code, it contains the variables and introduction scrip. An expression statement is a line of code that expresses something, for example the std::cout << “hello world!” ; You can identify these statements in their ending with a ;. These differ from the Deceleration statements by the fact that a deceleration statement will declare a variable of some kind, though they also end in the ;. finally the return statement will bring the code to a close, returning the 0 value in the case of everything functioning properly.

In short we have the structure of the game.

First the “iostream” library we’re using to print to the screen, then the main function that starts the program.

Then a series of instructions to print and assign values to variables and then print again.

The return statement is because we declared the Main function as “int,” and that means we HAVE TO return an integer, but since we don’t need to return any value, we just make it 0 to exit the function and end the program.

What i think each part of the code does in my understanding;
-Preprocessor directive- this helps us in defining any part of pre defined code that we can use, like one of them is ‘iostream’.
-Main Function- not exactly sure but this is the part which decided the output and anything inside this is what gives us the output.
Expression statement- This is what we want our code to express maybe :D, anything that compiler will use and store for output. Like we want something to be printed or calculated so anything we write in order to achieve that is an expressions statement.
Declaration statement- Defining something, assigning values and setting up rules.
Return- tells the compiler that this is the end of the code, not sure why we need to do this. Is compiler that dumb. We will see :smiley:

1 Like
  • Preprocessor Directive - It integrates a specific library to use with some of its built-in functions to use.

  • Main Function: - It is our main runtime function that takes all arguments to be executed with a logical form.
    Expression Statement: - assigns some value to specific variable.
    Declaration Statement: - Declares the starting state of a variable. It can be empty and declared later.
    Return Statement: - Returns the result of any logically performed function to be used elsewhere or just to save the variable at some sort.

Preprocessor Directive: Will copy in another library of code to yours before the rest of the code is compiled.
Main Function: Defines the main function and tells the compiler where the code begins.
Expression Statement: These are executable pieces of code.
Declaration Statement: These are statements that declare things such as variables in your code.
Return Statement: The return statement returns whether there were errors.

Preprocessor Directive- Foundational code imported from outside source
Main Function- starts the process
Expression statement- Instructions on how to format
Declaration statement- what to include
Return Statement- how many times you repeat process

  • Preprocessor directive : Includes files needed for the code. Read before reading our main function.
  • Main function : Function executed in order to run the game. Other functions may be called here.
  • Expression statements : Can do a lot of different things. Here, it is used to change our variables, or define outputs.
  • Declaration statements : Where variables and const are declared, or in other words, are created.
  • Return statements : Used to exit the function. Since it’s an int, we return 0. If it returns anything else, there’s a bug.

(Once again, sorry if my english is broken ! Not my first language !)

The Preprocessor Directive - Is used to include the library that will be using

Main Function- This is used to pass arguments into a function.

Expression Statement: Statements that are printed to the terminal and also end in a semi-colon

Declaration statement -> There are used to declare variables.
Return Statement -> This is used as mean of ensuring and checking the code had been successfully executed.

My understanding pieces of codes:

  • Preprocessor directive: This is a code which includes some functions or tools we can use in actual program. Compiler “read” this first.
  • Main function: A place where are the main parts of the program.
  • Expression statement: A part of the code where we do something with variables or comunicate human/program or vice versa.
  • Declaration statement: A part of the code where we create something new in program thats occupying some memory space.
  • Return statement: A part of the code where the function end working. This is a main goal of function to return something.

Preprocessor directive: Adds pre-written function(s) that we can use later in our code.
Main function: The “starting point” of our code, it will lead to other functions.
Expression statement: Has a variety of uses, it is an expression ended with a semi-colon.
Declaration statement: Declares a space in memory for a variable or constant.
Return statement: Can end or restart the program.

Privacy & Terms