+ 2
What is the use of main() and why is it compulsory??🤔
4 ответов
+ 3
the main function is the driver code of the whole c++ program. It indicates the starting point of instructions when the program is executed.
+ 2
About main function
C language
https://en.cppreference.com/w/c/language/main_function
C++ language
https://en.cppreference.com/w/cpp/language/main_function
+ 1
In C++, the “main()” function is treated the same as every function. The only difference is that the main function is “called” by the operating system when the user runs the program.
It is used as entry point of program. Every program starts execution from main() function. Like, other function it has also return type and parameters or signatures. By default, return type of main() in C programming language is void and for C++ is int.
+ 1
The main is the first executable statement for every programming language
From main we can call various userdefined functions or create code based on requirement