What this C++ code-review question tests
This is an easy code-review question designed to assess whether you can spot potential issues in a short C++ snippet. It is the kind of question quant firms use in screening rounds to gauge attention to detail and familiarity with common pitfalls in the language.
The question asks you to read code carefully and identify problems—whether they are logical errors, undefined behaviour, memory issues, or violations of best practices. Success requires knowledge of how C++ handles scope, resource management, and variable lifetime. Interviewers are testing both your ability to reason about code flow and your grasp of language semantics.
- Scope and lifetime of variables
- Memory management and pointer safety
- Undefined behaviour in C++
- Common syntax and semantic pitfalls