In the Main() function of C++

Chelsea Cruise
May 19, 2021

--

Every program contains a main function which is executed automatically when the program is run.
The most basic program that can possibly be run in C++ will do so with just a main function.

main should return an integer which indicates if the program exited successfully.
This is done so by writing the return type, followed by the main function name, then follows the empty arguments. Here is an example:

int main()

The arguments of the main function is enclosed in parentheses: ( and ) .
However, the body of the main function come after the parentheses in curly brackets: { and } .

Here is an example of our main function in use:

writing our main function

Now we will compile our code. The program will not have any output, but it should compile without any errors.

Compiling our code

--

--

Chelsea Cruise
Chelsea Cruise

Written by Chelsea Cruise

Unity Developer, Software Engineer, Game Designer, Graphic Artist

No responses yet