Explanation of each section of code

#include <iostream>

This is telling the compiler to copy the code from the iostream header file before compiling the rest of the code.

int main()

The operating system looks for the main function when the program runs.
It’s the starting point of the program.
Without it the program will not build.

Expression statements
These are for printing messages to the terminal for the player to read and for storing the code the player enters.

Declaration statements
These are for reserving the places in the computer’s memory for the codes the player will enter.

return 0;

The return statement in the main function is necessary because the value returned is used as an exit status for the operating system.

1 Like
#include <iostream>

This is going to be addressing to the computer that it will be “including” a prewritten code structure that is being declared by the header to be used in the compiled code

int main()

This is the beginning of the program, the OS is going to be looking for this function to compile and run, without it, no program can be run

Expression Statements
Expression statements are used as a way for code to be expressed to the players

Example:

std::cout << "Hello!"

Declaration Statements
Declaration statements are used to declare variables or other statements that need to reserve spots in the memory

return 0;

This is declaring the exit point from the main function, the end of a program

#include <iostream>

This section is telling the program to include a pre-made code when compiling the full code.

int main

This is the beginning of the program and an integral part of the code. Without this function, the program will not work.

Expression Statements

These statements allow the user to print information for the program to display.

Declaration Statements

These statements reserve spots in the computer’s memory for the codes that is entered by the user.

return 0

This is the return statement. It signals the end of the main function, telling the program to end.

The preprocessor directive

#include<iostream> 

is telling the compiler to copy the code in the library iostream into our code.

The main function

int main()

contains the main body of our program.
The return statement

return 0;

ends the main function and thus the program.
The expression statements are expressions that end with a semicolon.
The declaration statements declare new components in our program.

#include
let us use others programs in ouer code

int main()
the entry points and must-have in our program
and include
different kinds of expressions followed with (:wink: like statements and declarations (declaration because we declared our variable in it ).
return 0;
return the statement of our functions

this not emoji ( ; )

const ; means constant values that cannot be changed.

Preprocessor directive

#include <iostream>

It is very important to have this, it instructs the compiler to run the iostream file before the rest of the code is compiled

Main function

int main()

This is to introduce the body of our code

Expression Statements
It is very simple, if it is followed by a semi-colon, it is an expression statement
Declaration Statements
It is to declare something (for example, we declared variables)
Return Statement
It is to end the program, the main function ends here

Preprocessor Directive
includes code in out program prewritten by someone else.

Main Function
main function of our program that summarises out program functionality

Expression Statements
lines containing common code statements followed by a semicolon

Declaration Statements
lines that declare variable, of note they also end with semicolon

Return Statement
return 0 if the program does not have an error/bug

1 Like

Awesome job for doing the challenges guys!

Privacy & Terms