+ 2
Why we use return 0;
15 Antworten
+ 3
Because your function type is int.If you use void, it will simply be return;
+ 8
Because that is the return data type as prescribed by the standard.
See: https://isocpp.org/std/the-standard
+ 7
In c++,
A return 0 for main() means program executed normally.... And it can't have a return type other than int...
+ 4
The C main function has a return value of type integer, to give the operating system a feedback about the program execution. As a convention a zero return value indicates, that the program execution was successful.
+ 2
For normal functions any valid data type... Either built in like int, float, char, string or user defined like a class can be return type
+ 2
basically your main function is exiting with a status code. 0 as return indicates your program succeeded, other than 0 means it exited with an Error .
+ 1
If I use char,string type variable which return type can I use?
+ 1
It's not the variable, but function type.
+ 1
Why it can't have a return type other than int? Bro Saurabh B
+ 1
See.. It has standard return type int predefined whether u write it as int main() or just write main()... It is already predefined... Other return type gives error
+ 1
To tell the compiler that our code ends here
0
It depends upon which type of function you make. If you make a function of type int or anything else except void, you are to return something. In case of void, you do not need to return anything.
0
To return a value of data type
0
Because thats the end of your data and program. Some programs do not need return 0;
But instead use system("Pause"); to pause your program