मराठी

Evaluate the following expression as per Java priority and associativity. 50 % 9 + 50 % 8 + 50 % 7

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 [पृष्ठ ४५]

APPEARS IN

रूपा पंडित Computer Applications [English] Class 10 ICSE
पाठ 1 Revision of Class 9 Syllabus
Exercises | Q 4. (vii) | पृष्ठ ४५
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×