Which statement ends a function and returns control to the caller?

Prepare for the IGCSE Algorithms and Pseudocode Exam. Study with comprehensive questions covering key algorithms and pseudocode techniques. Access hints and explanations to gear up for your exam success!

Multiple Choice

Which statement ends a function and returns control to the caller?

Explanation:
The main idea here is how a function hands control back to wherever it was called from. The return statement is used to end a function and send a value (if one is provided) back to the caller. When execution reaches a return statement, the rest of the function is skipped, and control immediately resumes at the point after where the function was invoked, with the returned value available to the caller. Why this is the best fit: a return statement explicitly terminates the function’s execution and transfers control back to the caller, which is exactly what the question describes. Why the others aren’t correct on their own: a for loop repeats a block of code until its condition is met; it doesn’t by itself end the function or return control. An output command performs an action (displaying information) but does not exit the function. A case statement selects a branch to execute, but again doesn’t terminate the function or return control unless there is a return within the chosen branch.

The main idea here is how a function hands control back to wherever it was called from. The return statement is used to end a function and send a value (if one is provided) back to the caller. When execution reaches a return statement, the rest of the function is skipped, and control immediately resumes at the point after where the function was invoked, with the returned value available to the caller.

Why this is the best fit: a return statement explicitly terminates the function’s execution and transfers control back to the caller, which is exactly what the question describes.

Why the others aren’t correct on their own: a for loop repeats a block of code until its condition is met; it doesn’t by itself end the function or return control. An output command performs an action (displaying information) but does not exit the function. A case statement selects a branch to execute, but again doesn’t terminate the function or return control unless there is a return within the chosen branch.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy