A software-engineering coursework exercise: a FIFO queue built on a fixed-size array (MAX_SIZE = 10) with a console menu to try every operation.
| Function | What it does | Complexity |
|---|---|---|
init() |
Sets front = 0, rear = -1 |
O(1) |
enqueue(x) |
Adds x at the rear (menu checks isFull() first) |
O(1) |
dequeue() |
Removes and returns the front element (menu checks isEmpty() first) |
O(1) |
size() |
rear - front + 1 |
O(1) |
isEmpty() / isFull() |
Bounds checks | O(1) |
display() |
Prints elements front → rear | O(n) |
flowchart LR
E["enqueue → rear"] --> Q["[ front · · · rear ]"] --> D["dequeue ← front"]
g++ Untitled1.cpp -o queue
./queue1. Enqueue
2. Dequeue
3. Size
4. Display all element
5. Quit
- FIFO (first in, first out) ordering
- Front/rear index management in a linear array
- Overflow and underflow checks
Note
This is a linear (non-circular) queue kept as a learning snapshot: slots freed by dequeue aren't reused, and the source is in its original classroom form, so it may need small fixes (explicit return types, the stray line inside main) to compile on modern compilers.
By Intikhab Azam — AI & automation engineer
Keywords: queue in C++ · array implementation of queue · data structures and algorithms · enqueue dequeue · FIFO · DSA lab