Advertisements
Advertisements
प्रश्न
Evaluate the following expression as per Java priority & associativity.
79 % 2 + 2 % 79
मूल्यांकन
Advertisements
उत्तर
Priority (Precedence): Modulo (%) has higher precedence than addition (+), so both modulo operations are evaluated first.
Associativity: Since the two modulo operators share equal precedence, they evaluate from left to right.
- 79 % 2: Leaves a remainder of 1 (since 2 × 39 = 78).
- 2 %
- 79: Since 2 is smaller than 79, it cannot be divided, leaving the entire number as the remainder, 2.
- 1 + 2: Addition completes, giving a final answer of 3.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
