Answer:

1. This is a common programming trick. Often you need to know the oddness and eveness of an integer.

Remainder with Negative Integers

The remainder operator can be used with negative integers. The rule is:

  1. Perform the operation as if both operands were positive.
  2. If the left operand is negative, then make the result negative.
  3. If the left operand is positive, then make the result positive.
  4. Ignore the sign of the right operand in all cases.

For example:

17 %  3 == 2     -17 %  3 == -2     
17 % -3 == 2     -17 % -3 == -2

You may wish to practice with the following:

Expression ResultExpression Result
7 -3 -7 5
-10 5 10 -6
-129 100 -1999 -100
-17 2 -18 2

QUESTION 15:

Does the value for π (pi) ever change?