Why return 0 doesn't affect output? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why return 0 doesn't affect output?

21st Jan 2018, 11:52 AM
SHUBHAM
SHUBHAM - avatar
3 Answers
+ 27
21st Jan 2018, 11:56 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 5
Simply because it is the last statement of a program. What does return actually do? it brings you out of the whole block of the function regardless of the position it is placed at...which is already going to happen since you have finished your code and all of its logics. So return 0 doesn't affect much.
21st Jan 2018, 12:06 PM
Infinity
Infinity - avatar
+ 1
in the context of c or c++ if you miss return statement in main then compiler will add it for you.
21st Jan 2018, 3:02 PM
shobhit
shobhit - avatar