But i don't really get what happens when x < y
The result of division is 0 and the remainder is x. 2 % 6 would result in 2. If you assign the result back to x, the behavior is a no-op because the same value is assigned back.The book says that the program basically wraps around the queue back to 0 when the end of the array is encountered.
Yes. Let's say that N is 11 and tail is 10. 10 % 11 is 10, which holds true for any case where x < y in x % y. That's why it's safe to always take the remainder when wrapping indexes like this.
Once tail becomes 11 though, the wrapping becomes apparent. 11 % 11 is 0, obviously. 12 % 11 is 1, 13 % 11 is 2, and so on until x once again becomes evenly divisible by y at 22 and the result wraps around to 0. Repeat until you get bored or exceed the limits of a signed integer. :)