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?

  1. A.

    The program pauses and waits for user input.

  2. 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.

  3. C.

    The function restarts from the beginning in a continuous loop.

  4. 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.

Explore the full course: Rssb Senior Computer Instructor