C++ Queue

A queue is a FIFO (First in First Out) structure and physically it can be implemented either as an array or as a linked list. Whatever
way a queue is implemented, insertions take place at the "rear" end and deletions at the "front" end.

Array Queue

When a queue is created as an array, its number of elements is declared before processing. The beginning of the array becomes its "front" end
and the end of the array becomes its "rear" end. The terms "front" and "rear" are used in describing a linear list only when it is implemented as a
queue.

"Front" stores the index of first element in the queue and "rear" stores the index of the last element in the queue. The number of elements in a queue at
any given time can be calculated from the values of the "front" and the "rear".
If front = 0 then number of elements = 0
else number of elements = front - rear + 1.

C++ Queue Example

Here are some example programs listed, demonstrating the concept of queue in C++ practically.