What happens to the execution of a program when a return statement is reached…
2026
What happens to the execution of a program when a return statement is reached inside a function?
- A.
The program pauses and waits for user input.
- B.
The function immediately exits, and the flow of control goes back to the point next to the statement from where the function was called.
- C.
The function restarts from the beginning in a continuous loop.
- D.
The entire program terminates and closes.
Attempted by 470 students.
Show answer & explanation
Correct answer: B
When a return statement is executed inside a function, the function stops executing immediately and control returns to the caller. The program continues running from the next statement after the function call, rather than terminating completely or restarting.