The remainder operation finds what is left after dividing one positive integer by another. Written with %, it helps a circular queue wrap an imagined index back into a static array. section 9.7
Use the divisor as the array length:
- For an eight-element array, indexes run from 0 through 7. section 9.7
- Convert a virtual index to a real index with virtual_index % 8. section 9.7
- This lets a rear or front pointer re-enter at index 0 after passing index 7. section 9.7
Wrapping index 8
Because 8 % 8 == 0, virtual index 8 refers to array index 0. Likewise, 9 % 8 == 1 and 10 % 8 == 2. section 9.7


