+ 2

What is the use of main() and why is it compulsory??šŸ¤”

21st Oct 2021, 2:32 AM
John Lukose Cochettu
John Lukose Cochettu - avatar
5 Answers
+ 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.
21st Oct 2021, 2:57 AM
Danielle Bagaforo Meer
Danielle Bagaforo Meer - avatar
21st Oct 2021, 7:35 AM
Ipang
+ 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.
21st Oct 2021, 4:59 AM
Arun Jamson
Arun Jamson - avatar
+ 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
22nd Oct 2021, 8:59 AM
sree harsha
sree harsha - avatar