7.4 Returning in an actual programming language

Depending on the programming language, the execution of a “return” statement can deviate from our pseudocode discussion.

In C (and most C-derived) programming language, a “return” statement is always followed by jumping to the end of the subroutine. This means that no statement can execute after a “return” statement and before the end of a subroutine.

In other words, a “return” statement does not only specify a return value, but it also ends the execution inside a subroutine. You must be extra careful when you use a “return” statement because a subroutine can contain dead code that has no chance to execute after a “return” statement.

Pascal and its derived programming languages, on the other hand, are consistent with the definition of “return” in this module.