Evaluate each of the following expressions and give the valu
Evaluate each of the following expressions, and give the value of any variable used in the expression after the expression is executed. For each instruction assume the variables are given the following values. x = 3; y = 5; z = 7; If a variable changes in one expression, assume it is reset to its original value before performing any later expressions (i.e., x is 3 at the beginning of each expression). The first is done as an example. Show the steps used to get your result. 3 + x++ - --y ((3 + (x++)) - (--y)) ((3 + 3) - (--y)) ((3 + 3) - 4) (6 - 4) 2 x = 4 y = 4 x += y *= z^= x z >> = y >>= x == 2 x = y == z == y x^= y|= z &= 10 z += y += ++x z *= y = x += 1 z %= x-= --y - 3
Solution
a.
x += y *= z ^= x
(x (+= y (*= z (^= x))))
(x (+= y (*= 4)))
(x (+= 20))
23
x = 23.
y = 20.
z = 4.
b.
z >>= y >>= x ==2
(z >>= (y >>= (x ==2)))
(z >>= (y >>= 0))
(z >>= 5)
0
x = 3.
y = 5.
z = 0.
c.
x = y == z == y
(x = (y == (z == y)))
(x = (y == 0))
(x = 0)
0
x = 0.
y = 5.
z = 7.
d.
x ^= y |= z &= 10
(x ^= (y |= (z &= 10)))
(x ^= (y |= 2))
(x ^= 7)
4
x = 4.
y = 7.
z = 2.
e.
z += y += ++x
(z += (y += (++x)))
(z += (y += 4))
(z += 9)
16
x = 4.
y = 9.
z = 16.

