Why do we need main() function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why do we need main() function?

25th May 2017, 12:23 PM
Harsh Priyadarshi
Harsh Priyadarshi - avatar
2 Answers
+ 2
the main function only run when you execute
25th May 2017, 1:45 PM
MOHANRAJ D
MOHANRAJ D - avatar
0
it is a legacy of C. the loader will start at main() and execute the program to end. perhaps C picked this up from it's predecessors. in Java, the JVM's loader will start at main().
25th May 2017, 1:08 PM
Venkatesh Pitta
Venkatesh Pitta - avatar