Scope of a local variable in general
The scope of a local variable extends from the point in the function where it is declared until the end of the block in which it is declared.
In the functions in Listing 4, that block consisted of the entire body of the function. Thus, the scope extends from the point at which the variable is declared to the end of the function.
However, in the case where a variable is declared within a block that is nested within another block, the scope of a variable ends at the end of the nested block in which it is declared.