A variable declared inside a block is visible from its declaration to the end of that block. An inner block may declare another variable with the same name; this hides the outer one within the inner block. Prefer clear names to avoid accidental shadowing.
Read the example
The complete program appears below. Read it first, predict the output, then run it.
Expected output
Inner: 2
Outer: 5
Practise
Rename the inner count to batch_count, then add the outer count to it.
Common mistake
A local variable does not remain accessible after its scope ends. Do not return a pointer to an automatic local variable.