(Order of Evalution) State the order of evaluation of the operators in each of the following C++ statements and show the value of x after each statement is performed.
a) x = 7 + 3 * 6 / 2 - 1;
b) x = 2 % 2 + 2 * 2 - 2 / 2;
c) x = ( 3 * 9 * ( 3 + ( 9 * 3 / ( 3 ) ) ) );
Solution:
a) 2, 3, 1, 4 (15)
b) 1, 3, 5, 2, 4 (3)
c) 4, 5, 3, 1, 2 (324)
X = 4 % 6 + (5 / 3 * (14 /4))
ReplyDelete