Return 0 in C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Return 0 in C++

what is the essence of writing return 0; at the end of C++ code? I noticed that even if i write return 1; or return 100; the output is still correct.

20th Aug 2018, 1:01 PM
Ayorinde Akanbi
Ayorinde Akanbi - avatar
3 Answers
+ 6
Ayorinde Akanbi int main() is designated start of c++ code... as it is int, return type of function is int which ask us to return some value... you can return any int value based on your wish.. General practice is that people return 0 to indicate that code executed okay without any error... negative value return is used to indicate some issue... for example, -1 for file not found, -2 for file access issue...etc..
20th Aug 2018, 1:37 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
How can I code de Euler number in C++?
9th Sep 2018, 7:19 PM
desire.barutwan
0
The Euler number
9th Sep 2018, 7:20 PM
desire.barutwan