35.7k views
4 votes
.When the ______ statement is executed, the variable or expression is evaluated and the resulting value is returned as the output of the function.

1 Answer

3 votes

Answer:

return.

Step-by-step explanation:

When a "return" statement is executed then the given expression or variable in the function is evaluated and the result will be returned by the function when the function is called.With the help of return statement, we can terminate the execution a method/function and then give control to the calling function.

Example:

#include <bits/stdc++.h>

using namespace std;

long long sq( int s )

{

/* here "return" will first execute the expression and then

return the value to the calling function i.e. sq() in the main

function.

*/

return( s * (long long)s );

}

int main()

{

long long y;

int x = INT_MAX;

// sq() will return a value and that value is store in the variable "y"

y = sq( x );

cout<<y<<endl;

return 0;

}

User Hugh Allen
by
7.9k points

No related questions found