+ 2

is it really necessary to put return 0 at the and of a int main()?

24th Jan 2018, 12:58 AM
pelham Dathorne
pelham Dathorne - avatar
6 Answers
+ 10
no, you can put any number you want, 0 is usually used to show that you program made sucesfull end
24th Jan 2018, 12:59 AM
Vukan
Vukan - avatar
+ 10
i can see that here on sololearn compiler don't show any error if you delete return statment...
24th Jan 2018, 1:02 AM
Vukan
Vukan - avatar
+ 5
As pointed out by Jamie, Vukan, and in reference to: http://www.stroustrup.com/bs_faq2.html#void-main "... In C++, main() need not contain an explicit return statement. In that case, the value returned is 0... "
24th Jan 2018, 2:06 AM
Hatsy Rei
Hatsy Rei - avatar
+ 3
thanks
24th Jan 2018, 1:00 AM
pelham Dathorne
pelham Dathorne - avatar
0
thx everyone
24th Jan 2018, 2:07 AM
pelham Dathorne
pelham Dathorne - avatar