3Rewrite the following five assignment statements into a sin
3.Rewrite the following five assignment statements into a single statement using prefix and postfix
increment and decrement operators as necessary. Assume all variables are int variables.
x = y + 1;
y = y + 1;
z = z-1;
x = x-z;
x = x + 1;
Solution
x = (++y - --z) +1;
Explaination of individual statements:
here,
++y ==> y = y + 1;
--z ==> z = z - 1;
(++y - --z) ==> x-z
(++y - --z) +1 ==> x = (x) + 1;
