When using compound assignment operators, e.g x += y; which is equal to x = x + y; the lvalue (x) is evaluated only once. It means that x is saved before calculating the sum x + y.
So in our case the left most a[0] value is evaluated before the right part is. a[0] = 2, a[1] = 3 and a[0] ^= (a[1] ^= a[0] ^= a[1]); is equal to a[0] = a[0] ^ (a[1] ^= a[0] ^= a[1]); and it's equal to a[0] = 2 ^ (a[1] ^= a[0] ^= a[1]); Therefore after executing the part in brackets (a[1] ^= a[0] ^= a[1]) a[1] will be equal to a[0] (2) and a[0] ^ a[0] (or 2 ^ 2) gives us a zero.
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment