If you exchange 372 pennies for dollar bills, how many bills do you get? How many pennies are left over?
Answer:
- Number of dollar bills is
372 / 100 == 3 - Left over pennies is
372 % 100 == 72
Practice with Remainder Operator
For positive numbers, 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:
QUESTION 16:
If X is odd, what is X%2?