What this C++ language-knowledge question tests
This is an easy C++ question that probes your understanding of core language semantics—specifically, how the compiler handles scope, variable shadowing, and output behavior. It's the kind of question quant firms use to quickly verify that a candidate reads code carefully and understands what actually executes, rather than what they assume will execute.
To answer correctly, you need to trace through the snippet line by line, paying attention to declaration scope, any name collisions, and what gets sent to standard output. The question rewards precision: a small oversight in reading the code can lead to the wrong answer.
- Variable scope and shadowing
- Output stream behavior
- Code flow and execution order