+ 3

why do we need to put return 0;

because i think that the program will run without return 0; am i right?

9th Sep 2018, 6:23 AM
Newbie
Newbie - avatar
4 Answers
+ 9
I think it might run without returning 0 but sometimes you want to know from outside the program that it ran without any errors. I have seen cases where a non-zero error code is sometimes returned by a program to the operating system to indicate that there was an error during operation. return 0 usually means that the program ran without errors.
9th Sep 2018, 6:28 AM
Sonic
Sonic - avatar
+ 4
Ok thank you guiz
9th Sep 2018, 6:36 AM
Newbie
Newbie - avatar
+ 4
It is OK to omit the return statement for main() in C++. http://www.stroustrup.com/bs_faq2.html#void-main
9th Sep 2018, 7:28 AM
Hatsy Rei
Hatsy Rei - avatar
9th Sep 2018, 6:32 AM
Ketan Lalcheta
Ketan Lalcheta - avatar