Why is the return statement is required in a function body?
When a function is called control is transferred from the calling function (main program) to the called function (sub-program). The statements of the called function are executed and finally the called function is terminated and sends the required result back to the calling function. The return statement is used to send the result from the function to the main program, thus terminating the called function.
The syntax is:
return;
Or
return(expression);
The first form does not return any value, where the second function returns the value of the expression.
Thanks
Mukesh Rajput
Post A Comment:
0 comments: