Difficulty: Easy
Correct Answer: The program will print the output 2.
Explanation:
Introduction / Context:
The problem focuses on default parameters and operator semantics in C++. It asks you to evaluate an expression that uses pre-increment and pre-decrement with integer operands and the modulo operator, all inside a class method invoked with explicit arguments.
Given Data / Assumptions:
Concept / Approach:
Pre-increment ++x yields 6. Pre-decrement --y yields 4. The modulo operation with integers computes 6 % 4, which equals 2. The method prints this result directly.
Step-by-Step Solution:
Verification / Alternative check:
Replacing pre- with post- (x++ % y--) would evaluate to 5 % 5 → 0 first, but the code explicitly uses pre-operators, so the printed result is 2.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing the free Tester declaration with the class method; mixing up pre- and post- increments which change the numeric result; overlooking that modulo is only valid for integral types (which we have here).
Final Answer:
The program will print the output 2.
Discussion & Comments