STRUCTURE OF PROGRAM (part 3)

Posted on at


STRUCTURE OF PROGRAM (part 3)

int main ()
These lines corresponds to the beginning of the definition of the main function. The main function is the point by where all C++ programs start their executions, independently of its location within the source codes.

It does not matter whether there are other function with other name defined before or after it - the
instructions contained within this function's definitions will always be the first one to be executed in any
C++ program. For that same reason, they are essential that all C++ programs have a main function.
The word main is followed in the codes by a pair of parentheses (()). That is because it is a functions
declaration: In C++, what differentiate a function declaration from other type of expression is this
parentheses that follow its name. Optionally, these parentheses may encloses  lists of parameters within
them.


Right after these parentheses we can find the body of the main functions enclosed in braces ({}). What is
contained within these braces is what the function does when they are executed.





About the author

160