Computer Applications

Given: x += x++ + ++x + --x
Find the value, when x=5.

  1. 23
  2. 21
  3. 22
  4. 24

Java Operators

63 Likes

Answer

23

Reason — The expression is calculated as follows:

x = x + (x++ + ++x + --x)       (x = 5)
x = 5 + (5 + ++x + --x)         (x = 6)  
x = 5 + (5 + 7 + --x)           (x = 7)  
x = 5 + (5 + 7 + 6)             (x = 6)  
x = 5 + 18
x = 23

Answered By

36 Likes


Related Questions