English

Evaluate the following expression as per Java priority and associativity. 49 − 28 − 4 * 3

Advertisements
Advertisements

Question

Evaluate the following expression as per Java priority & associativity.

49  − 28 − 4 * 3

Evaluate
Advertisements

Solution

Priority (Precedence): Multiplication (*) has higher precedence than subtraction (−), so it is evaluated first.

  • 4 * 3: Multiplies first, giving 12. The expression becomes 49 − 28 − 12.
  • 49 − 28: Subtraction operators share equal precedence and evaluate from left to right. This gives 21.
  • 21 − 12: Subtraction is complete, giving a final answer of 9.
shaalaa.com
  Is there an error in this question or solution?
Chapter 1: Revision of Class 9 Syllabus - Exercises [Page 45]

APPEARS IN

Rupa Pandit Computer Applications [English] Class 10 ICSE
Chapter 1 Revision of Class 9 Syllabus
Exercises | Q 4. (iii) | Page 45
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×