Stack in C — push/pop/print (and why index starts at 0)

A stack is “Last In, First Out”. In arrays, index starts at 0 because the first element is at base address + 0 offset.

Common mistake

Many beginners update top wrongly. Treat top as “index of last element”. Empty stack means top = -1.

← Back to Notebook