Computer Applications

Evaluate the expression when the value of x = 2:

x = x++ + ++x + x

Java Operators

ICSE Sp 2024

105 Likes

Answer

Output
10
Explanation

Initially, x = 2. The expression is calculated as follows:

x = x++ + ++x + x
x = 2 + ++x + x          (x = 3)
x = 2 + 4 + x               (x = 4)
x = 2 + 4 + 4               (x = 4)
x = 10

Answered By

64 Likes


Related Questions