Enqueue and dequeue values and watch the C++ run one line at a time. The queue lives in a fixed array of 8 ints. front marks the head, where items leave, and rear marks the tail, where items join. Both move to the right and wrap from [7] back to [0].
int data[8]main()The % CAPACITY is what makes the array circular: after index 7 comes index 0. When the queue is empty and when it is full, rear sits just behind front, so count is how the code tells the two apart.