preprocessor directive intakes loads of code from the respective lbrary included. so here we have through which we are able to perfrom the cin and cout operations.
the main fuction is where the program is being executed.
the expression statements are those statements which are giving an output to the user.
declaration statements are which hold the value in it like the const int.
return 0 is to run the program wiithout errors.
#include = preprocessor directive which tells the complier to include other code from outside the program in our program.
int main () = main function. I’m not totally sure what it does, all I remember is that all C++ programs need it and our code won’t build without it. I think it’s really just the beginning of the program?
return 0; = I’m pretty sure this just ends the program after it’s run successfully.
The expression statements are printing things to the terminal and the declaration statements are declaring our variables.
What the program does, in summary is include the iostream headerfile to include the iostream code before our program begins, then the program starts, prints some text, declares some constant variables and prints those variables to the terminal before stopping.
#include is use to bring a codes from another library to be used in your code.
main() is a function which allows the compiler to read the code and also allows the user to write code more organised. return statement ends the function.
There are declaration statements, which declares the variables( which are lines of code that starts with a datatype such as int/float and initialised the values/data.
Expression statements are the lines of code that are the main code that does what you tell the code to do, such as using a variable value to be printed out.
-
#include - It is a preprocessor directive which includes the header files from the c++ library so that we can use its functions in our code.
-
main() - As its name says that it is a main function of our program which is the most important part of the program. Execution of the program starts from this main function.
3)Declaration statement - These statements are used to declare the variables which we are going to use in our program.
-
Expression statement - These statements generally tells our program what to do.
-
Return Statement - It is used in the end of the program which in main function tells the compiler that code is ended comes out of the main function.
What does our preprocessor directive do?
It tells the compiler that we will be using code from the iostream library.
Why do we have a main function? What does it’s return statement do?
All C++ programs require a main function to specify an entry or starting point. The main function returns an int value to the OS. A value of 0 indicates that the program ran without error.
Explain our expression and declaration statement that we have written so far, to summarise what our program is doing.
Our first set of expressions provide some intro to the player about our story and mechanics. Our declarations initialize our 3 code numbers, their sum, and their product. Our second set of expressions prints the sum and product values on their own lines.
So, the preprocessor directive is used to do some actions like “include a library in our code” before that our main function begin, the main function itself is needed in every c++ script in order to make some magic coding tricks, the return statemente is used in every function to give the signal 0 at the end of the function in order to communicate that the function is done correctly because if any other number appers it means that there is an error, in the end the expression statement means that our expression finish with a semicolon, and the only difference with a declaration statement is that in the last one we are declaring something like a variable, now to explain what our program is doing so far: including the iostream libary, show some strings to the user, declaring some variables, show on screen the results of our sum and product and in the end the return statement to close our function.
It copys code from a pre written lybrary in our code
We have a main fuction for make a program run, and to start using other functions previosly
writed before the main.
The return statement returns a value from a function
An expression statement is everything folowed by ; exept when it has a declaration or a return statement,
The declaration statement is where why declare the different values.
Our program give us some text and do some matematical operation with the variables declared
-
#include
mean copy all the code the header file iostream has into our code. -
the main function is the entry of our code where it will run and execute.
-
Expression statement we print out to terminal the instruction.
-
Declaration statement
- We declare our variables
- Calculate Sum and multiply all the variables.
-
Expression statement print out our result.
-
Return 0 we need because we declare our main function type is int and we need to return a value for our declared type.
What does our preprocessor directive do?
It allows for the program to include whatever is listed before it compiles the program. It is also read beforehand and is the first thing in coding the program.
Why do we have a main function? What does it’s return statement do?
We have a main function because it serves as an entry point for the program. The compiler looks for it first thing and runs it through. A return statement is used to see if there is error in the code at the end, where if it returns something other than zero, there is an error.
Explain our expression and declaration statement that we have written so far, to summarise what our program is doing.
The expression statement that we have written so far are there to indicate to the compiler to print out the strings we have typed. The declaration statement that we have written so far are there to declare the integers we have typed out. Our program is currently printing out text we have typed into strings and also printing out integers we have declared out where we set those exact variables to print out in the strings themselves.
What does our preprocessor directive do? - The preprocessor directive basically informs the computer where it should draw some code from. So before we start is says hey I need some things from here grab this
Why do we have a main function? What does it’s return statement do? - the main function is of course the main function of our code it is what is happening the most important thing and how it should react. What a return statement does it at the end of the code it says bring me this week
Explain our expression and declaration statement that we have written so far, to summarise what our program is doing.
For our expression statements we have written some simple lines of code including strings that basically expressing what the rules of our games are. The declaration statement is declaring certain variables so we actually have things that run within our game. Right now our program is basically generating 3 numbers that we have specified and then that is all.
It’s a header that allows us to use the cout output for our game, and it’s called a preprocessor directive because it is used before processing everything else I think.
The int main() function is the first thing the program looks for after preprocessing directives and it’s where it starts from. The return statement at the end of the function ends the game.
So our game is giving us some text outputs for story setup in the first set of expression statements. The Declaration Statements are declaring our variables and also making them unchangeable (constant). The final set of Expression Statements are showing us the value of 2 expressions declared earlier, first the sum of a, b, & c. Followed by the product of them on a new line.
The preprocessor is a library with a set of codes that allows us to use the functions of that library.
The main function is a function that we can say as the heart of the program and it’s an integer type function and we aren’t returning any values so we return 0.
an expression is basically where we take some values and declaration is something where we define a variable or do some calculation.
This is loading a string of code from a library. We put it at the top so that it will be compiled first and thus can be used for the code to come
The main function is required in all C++ coding for the program to run. The return statement is where the program ends and it lets us no whether or not we had any errors in our code. If the return comes back 0 as we set it then there were no issues.
Our expression statements are telling the computer what to output for the user to read. That includes text and numbers
Our declaration statements set values to integers that the expression statements use to know what to output such as int a = 6;
. first how to print hello world.
. second thing is declared variable of intager.
. third one is sum of values and product.
. fourth one is comments & statement.
What does our preprocessor directive do?
it essentially gives the code their “tools” so they can understand and identify what we’re even trying to say, which is why we always put it at the start of the code as the code also act like a “timeline” for it’s memory
Why do we have a main function?
we have the main function so it knows what it needs to do kinda like the “body” that holds all of the squishy “organs” or code inside without it there is no code being made
What does it’s return statement do?
the return statement is used so if theirs any problems it can tell us if there’s any contradictions or if we forgot to place the semi colen
Explain our expression and declaration statement that we have written so far, to summarize what our program is doing.
we told the computer to say some words to our audience which also taught us to write standard code like “std::cout <<” and then we told them what a,b and c are told them what to do with it via the sum and product and then we loop back around with return0; to check for problems
The preprocessor directive imports code that we can use that allow us to perform certain functions. For example, the iostream allows us to have input or output through cout or cin.
The main function houses the code that will be used to run the game. We have a main function because it is necessary for the file to run. The return statement returns an integer, 0, if the main function runs correctly.
The expression statements output lines of text to create the story we are trying to write with the game.
The declaration statements initialize variables and computations for the numbers that will be used for the game.
The preprocessor directive instructs the compiler to include the iostream file into the current file, allowing us to use the code from that file.
the main function is required for any C++ program and is the entry point of the program. Its return statement tells whether the program succeeded or failed, and the type of error if there is one.
the expression statements at the top print an intro to the game, instructing the user what to do.
the declaration statements create variables and assign literals to them. const indicates to the compiler that we don’t want to allow the variables to be set after they are declared. the sum variable uses the addition operator to add the a b and c variables. the product variable uses the multiplication operator to multiply the a b and c variables.
the expression statements at the bottom print the result of the sum and product calculations. the std::endl variable represents an end of line to be printed.
prepocessor directive helps us assing a filter to the code
without the main function we cannot compile the code and it is needed in every code
expression statements help us express something through the code into the compiler
declaration statements help us declare variables a name
return statement help us finish the code without any problem or bug
It gets access to a library of code that someone else has already made
We have a main function so that the program has something to execute and run. The return statement is there to satisfy the condition that the main function must return an integer.
Our expression statements are the premise and formatting of our program. The declaration statements define the variables we will be using in our program and the const makes them invariable.
The preprocessor directive gives instructions to the compiler to copy the contents of the header file into our code.
The main() function is necessary to run and build your code. It is the entry point of the program.
Our expression statements so far have given us the plot of the game and the output of our declaration statements, which assign three number to three variables and shows the sum and product of those variables.