KnowledgeBoat Logo

Computer Applications

int m,p; m=5; p=0; p= m-- + --m; The output will be:

  1. 11
  2. 10
  3. 8
  4. 12

Java Operators

20 Likes

Answer

8

Reason — Putting the values of variables in the expression:

Expression      Explanation
p = m-- + --mThis is the given expression. Initial value of m is 5.
p = 5 + --mAt this step, current value of m (which is 5) is used in the expression and then value of m is decremented to 4. Current value of m becomes 4 after this step.
p = 5 + 3--m first decrements the current value of m (which is 4) by 1 so m becomes 3. After that, this decremented value of 3 is used in the expression.
p = 8This is the final result of the expression.

Answered By

4 Likes


Related Questions