+ 1
What's return value really mean? Why return value called return value and how it works?
4 Answers
+ 21
The return type of a function tells what kind of value a function is supposed to return to the point from where it is called.
However, if you use 'void' as the return type of a function, it doesn't need to return anything.
It just performs the work written through the code, and returns the control back to point from where it was called.
āŖreturn x; causes the current function to return to the caller, evaluating to x. It is required except in functions returning void, in which case return; returns without a value.Ā
+ 12
TheĀ returnĀ statement terminates the execution of a function and returns control to the calling function.
Execution resumes in the calling function at the point immediately following the call.
AĀ returnĀ statement can also return a value to the calling function
So it called return dramatically because of it's grammatical meaning , it means to stop where you are and turn back your way from where you came from and in our case we will come back to "the calling function"
and as I said sometimes we don't turn back our way with empty hands , we can come back with a value
so it may seem funny the metaphor but that what "return"really do
+ 10
In most programming languages, the returnĀ statement is eitherĀ returnĀ or return value, whereĀ valueĀ is a variable or other information coming back from the subroutine
+ 4
return simply means to get the output of a function, you return a value back to were that function was called.