Q. What is the purpose of main() function?

Love and Share

Answers : In C, program execution starts from the main() function. Every C program must contain a main() function.  Like all C language functions, first comes the function’s name, main, then comes a set of parentheses.

 So the purpose of the main() function are:

 – main function is the starting point of the program. The first line of the code that the compiler complies and start understanding the flow of the program.

 – tells the compiler, about an initial point from where the program starts.

 – It returns an int value to the environment that called the program.

 – Whenever you compiles your code to executable file, the compiler searches for main() function as an entry for your program by default.

 – Recursive call is allowed for main( )

 – Program execution ends when the closing brace of the function main( ) is reached.

 – it is a well defined user defined function. Any user-defined name can also be used as parameters for main( ) instead of argc and argv

Love and Share

Leave a Reply

Your email address will not be published. Required fields are marked *