about main function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

about main function

can someone describe me about main() function and why it return 0. please describe it detailly,

24th Jan 2017, 5:03 PM
Diwas KC
Diwas KC - avatar
2 Answers
+ 3
execution of a program starts from main function C++ main function has to return a value because it is declared as "int main" which is given as return 0 some compilers support "void main" then there is no need of return..
24th Jan 2017, 5:16 PM
Athul P Ramachandran
Athul P Ramachandran - avatar
+ 2
main() function returns an integer value to allow the test of the execution. In case of error the program must return a error code (!=0) otherwise returns 0.
24th Jan 2017, 9:18 PM
Michael Isac Girardi
Michael Isac Girardi - avatar