Difficulty: Easy
Correct Answer: 237
Explanation:
Introduction / Context:
This checks your fluency with default parameters, pre-increment semantics, and casts from floating point to integer in C++. The order of operations is explicit because increments occur on local parameters before multiplication and addition in a straightforward expression.
Given Data / Assumptions:
CuriousTabFunction(20, 10)
→ x=20
, y=10
, z=5
(default for z
).++x * ++y + (int)++z
.
Concept / Approach:
Pre-increment increases the operand and yields the incremented value. Casting a float to int truncates toward zero. Multiplication and addition then combine these updated values deterministically (no sequencing pitfalls here because the operands do not alias the same object).
Step-by-Step Solution:
Verification / Alternative check:
Evaluating on paper or in a small REPL reproduces the same deterministic steps since there is no undefined behavior in this expression.
Why Other Options Are Wrong:
Common Pitfalls:
Forgetting that ++z
happens before the cast and truncation, or mixing up pre- vs post-increment results.
Final Answer:
237
Discussion & Comments