0

why we use only 0 (not other digits) after return in main function

18th Oct 2016, 1:08 PM
vikash tiwari
vikash tiwari - avatar
2 Answers
+ 2
The C++ standard forbids the use of a void return type for the main function http://www.stroustrup.com/bs_faq2.html#void-main So the main function must return a value. It can be any value. Most compilers use the return value of main to denote its "Exit Status", where 0 represents a successful exit status, and anything else (usually -1) represents an unsuccessful exit status.
18th Oct 2016, 4:33 PM
DaemonErrors
DaemonErrors - avatar
+ 1
if you created a function of integer type then you can return any value but "it should be in integer type " so if you want to return 5 then you do so, ->because function "int main() " or any "int abc()" tells you to return a integer not tells you to return 0 only. example :-int main(){ int a=1,b=4; return a+b; } here you not have to return 0 because function already return an integer value, which is a+b
18th Oct 2016, 5:48 PM
Chetan kumar das
Chetan kumar das - avatar