Is return statement compulsory in int main() function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is return statement compulsory in int main() function?

As far as I know , a function must have return statement if its return type is not void. But I came across many codes where there was no return 0; statement in the int main() function. But the code was run successfully without any error. Why is it so?

24th May 2017, 6:41 AM
Mystique
Mystique - avatar
1 Answer
+ 7
see lesson here. It will be automatically inserted by the compiler if not supplied
24th May 2017, 6:42 AM
jay
jay - avatar