Expressions and Arithmetic Operators

Read this chapter, which discusses arithmetic operations in greater detail along with solving expressions with mixed data types.

16. Practice with Remainder Operator


Answer:

  • Number of dollar bills is 372 / 100 == 3
  • Left over pennies is 372 % 100 == 72

Practice with Remainder Operator

For positive integers, INT % X means to fit as many X as you can into INT, and then the left over amount is the value of the expression. Try that with the following:

ExpressionResultExpressionResult
 3 5
10  510  6
129  1001999  100
17  218  2


Question 16:

If X is odd, what is X % 2?