0
hi can someone tell me what return mean in c++ language
2 Réponses
+ 2
return 0; in int main () tells the operating system that the program has finished. In another words, the program was successful and complete if there were no previous syntax errors or bugs.
You have another return, that can be used for boolean expressions like
Ex. if (5 > 3) {return true};
And you can also use return for returning a variable in an int, double , float, string, boolean functions, but not void function( it prints only).
Ex. int function ( ) {
int x = 2;
return x;. \\ returns value 2
}
Now x can be returned and reused in main function.
+ 2
- the word return means to give back something
- In code it is a statement in a function/program to give back a value after its work is done.
- Using this value we can know if the function/program worked properly.
return 0; //means all went well
if something went wrong 0 wont be returned.
- We can also use a returned value to use it anywhere else.
sum = x+y;
return sum;