Expressions and Arithmetic Operators
15. Taking an Integer Apart
Answer:
Yes
Taking an Integer Apart
The integer division operator /
and the remainder operator %
take an integer apart.
theInteger / divisorquotient
theInteger % divisorremainder
The original integer can be put back together again:
quotient * divisor + remaindertheInteger
In many calculations, it is convenient to do everything with integers, so both /
and %
are needed.
Question 15:
If you exchange 372 pennies for dollar bills, how many bills do you get? How many pennies are left over?