Answer: D. return
The keyword used to transfer control from a function back to the calling function is return.
Solution
The if is used as a conditional statement to check whether the expression it's true or false. The if isn't having any relevance in transferring the control back to a function.
The back and return aren't the keywords of the programing language.
The return statement ends a function's execution and hands control back to the caller function. Immediately after the decision where execution returns to the caller function, a value will also be returned to the calling function in a return statement. Hence, the keyword used to transfer control from a function back to the calling function is return.
Example:
#include<stdio.h>
int greater(int, int); /* Function prototype */
int main()
{
int a = 5, b = 2, c;
c = greater(a, b);
printf("The greater elements is = %d\n", c);
return 0;
}
int greater(int a, int b)
{
/* returns the value and control back to the main() function which is calling */
if(a>b)
return(a);
else
return(b);
}
In the given program, the main function is calling the greater function. After that, the greater function is returned and prints the output as 5.
☛ Related Questions:
Comments
write a comment