Stack•Easy
Pop Operation
Stack Pop Operation

The Pop operation removes and returns the top element of the stack.
Key Rules
- Underflow Check: Before removing an element, you must verify if the stack is already empty (
top < 0). If it contains zero elements, a Stack Underflow condition occurs, and the pop operation is rejected. - Access Value: If elements exist, retrieve the element value stored at
arr[top]. - Decrement Top: Decrement the index pointer
topby 1 to logically remove the element.
Visually
Before Pop(): After Pop():
Index [2]: [ 30 ] ◄top Index [2]: [ Empty ]
Index [1]: [ 20 ] Index [1]: [ 20 ] ◄top
Index [0]: [ 10 ] Index [0]: [ 10 ]