Computer Applications
If a = 8, find the value of a -= ++a + a++ + 4 - a + 6.
Java Operators
14 Likes
Answer
a = -10
Explanation
The given expression is evaluated as follows:
a -= ++a + a++ + 4 - a + 6
a = a - (++a + a++ + 4 - a + 6) [a = 8]
a = 8 - (9 + a++ + 4 - a + 6) [a = 9]
a = 8 - (9 + 9 + 4 - 10 + 6) [a = 10]
a = 8 - 18
a = -10
Answered By
7 Likes
Related Questions
Observe the following code and find that how many times will the loop execute?
int sum = 0, score = 0; double t; do { score = score + 1; sum = sum + score; } while(score <= 3); t = sum / 3;Write the Java statement for the following mathematical expression
Rewrite the following code using for loop.
int i = 1; int d = 5; do { d = d * 2; System.out.println(d); i++; } while(i <= 5);Name the operators listed below.
- ?:
- &&
- <=
- ++