Advertisements
Advertisements
प्रश्न
Evaluate the following expression as per Java priority & associativity.
50 % 9 + 50 % 8 + 50 % 7
मूल्यांकन
Advertisements
उत्तर
Priority (Precedence): Modulo (%) has higher precedence than addition (+), so all three modulo operations are evaluated first.
Associativity: Since the % operators share equal precedence, they evaluate from left to right.
- 50 % 9: 50 divided by 9 gives a remainder of 5 (since 9 × 5 = 45).
- 50 % 8: 50 divided by 8 gives a remainder of 2 (since 8 × 6 = 48).
- 50 % 7: 50 divided by 7 gives a remainder of 1 (since 7 × 7 = 49).
- 5 + 2 + 1: Addition completes from left to right (5 + 2 = 7, then 7 + 1 = 8).
let 5 + 2 + 1 = 8.
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 1: Revision of Class 9 Syllabus - Exercises [पृष्ठ ४५]
