What is return = 0; at the end of code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is return = 0; at the end of code?

Return = 0

6th Sep 2021, 8:05 PM
Amin
Amin - avatar
2 Answers
+ 7
The main function is generally supposed to return a value and after it returns something it finishes execution.The return 0 means success and returning a non-zero number means failure. Thus we "return 0" at the end of main function. But you can run the main function without the return 0.It works the same . Source: Stackoverflow Happy coding!
6th Sep 2021, 8:08 PM
mesarthim
mesarthim - avatar
+ 2
mesarthim is right. Important: I suppose you mean „return 0;“ and not „return = 0;“. The equal sign normally is an assignment, but as „return“ is a reserved word it can possibly not be a variable‘s name (which it would be in case of being placed before an equal sign).
6th Sep 2021, 8:53 PM
KatharinaSt