Home »
C Popular & Interesting Questions
Is main function in C programming language predefined or user defined?
The solution is:
main() is user defined (implemented by the user/programmer) whose prototype is declared in the compiler.
Please read complete article to learn better.
Is main() function predefined or user defined?
This is an interesting question, Is main() function in c programming language predefined or user defined?, in this article we will explain you what is main() in c programming language.
main() function is a user defined, body of the function is defined by the programmer or we can say main() is programmer/user implemented function, whose prototype is predefined in the compiler.
Hence we can say that main() in c programming is user defined as well as predefined because it's prototype is predefined.
Definition of main()
main() is a system (compiler) declared function whose defined by the user, which is invoked automatically by the operating system when program is being executed.
Use of main()
Its first function or entry point of the program from where program start executed, program's execution starts from the main. So main is an important function in c , c++ programming language.
Prototype of main()
Some of the main() prototype's given below:
void main(void)
{
/* Declaration part */
/* Executable part */
}
No return type and no argument.
int main(void)
{
/* Declaration part */
/* Executable part */
}
Integer type return type with no argument.
int main(int argc, char *argv[])
{
/* Declaration part */
/* Executable part */
}
int main(int agrc, char **argv)
{
/* Declaration part */
/* Executable part */
}
Integer type return type with command line argument.