MC logo

Assignment and Side Effects I

  Practice Questions

Given the following declarations:

int m = 1, n = 2, i = 0, j = 5;

Give the value of each expression, and state the values of the variables after the expression is evaluated. Consider each one separately; that is, assume each one appears immediately after the given declarations.

  1. m = n++ + 3

  2. m = ++n

  3. m = (n = 5) + 2

  4. i-- && (4 * ++m <= 4 || ++n - 2)

  5. --i || (4 * ++m <= 4 && n++ - 2)

  6. --i && (4 * ++m <= 4 && n++ - 2)

  7. j > n > m

<<Legal Identifiers Answer Assignment and Side Effects II>>