What this C++ variable initialization question tests
This is a medium-difficulty question that probes your understanding of variable scope and initialization semantics in C++. It rewards careful reading of control flow and the ability to distinguish between declaration, re-declaration, and initialization across different scopes.
To solve this type of problem, you need to track when a variable is first brought into existence with an initializer, as opposed to being declared without one, reassigned, or shadowed by a new declaration in an inner scope. The question tests whether you understand how C++ scoping rules and control-flow constructs interact—knowledge that prevents subtle bugs in real codebases.
- Block scope and scope shadowing
- Loop variable initialization vs. re-initialization
- Distinction between declaration and initialization
- Scope lifetime and variable visibility