Suppose we are using int main() and after that in the last of the program why we are writing that return o; | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Suppose we are using int main() and after that in the last of the program why we are writing that return o;

14th Dec 2016, 3:12 PM
chandraprakash
chandraprakash - avatar
2 Answers
+ 6
Since main() has return type of int, it has to return a number. return 0; indicates safe or successful termination, while anything else means abnormal termination. If you don't add a return statement to main(), the compiler will insert a return 0; for you. But it's a common convention to write it explicitly. You can always make main() void instead, though it's also a convention to write return; at the end anyway.
14th Dec 2016, 5:14 PM
Tamra
Tamra - avatar
+ 2
in int main () int is the return type of main function. it must return something . but if we have nothing to return we should simply return noth8ng which is return 0 .. i.e. need to write return 0
14th Dec 2016, 3:23 PM
kit y
kit y - avatar