+ 1
why return0 to terminate a program, why not return5
7 Respuestas
+ 3
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
+ 2
because in programming, 0 means successful execution
0
Remember your code is called by the operating system. Former OS where textual only and by default if a program returned 0 it meant it worked OK, it failed otherwise, usually each number indicating a different error.
0
it haven't different
you can return any number
but if you have a function you can return the result of your function.
for example:
int sum (int,int);
int main(void)
{
a=2;
b=3;
c=sum(a,b);
cout<<c;
}
int sum (int a,int b)
{
return a+b;
}
/////////////////^
result:
5
0
0 is a standard exit code for successful execution, that's exactly how I check my Runtime.exec() calls in Android for success execution.
- 2
there is no diffrence. you can use return 5
- 3
bcz return 0 returns the value of program with 0 and after termination the program will start from beginning