C++ program to implement stack operations using array
To write a program to implement stack operations using array.
PUSH (STACK, TOP, MAXSTK, ITEM)
This procedure pushes an ITEM onto a stack.
1. [Stacl already filled ?]
If TOP = MAXSTK, then: Print: OVERFLOW, and Return.
2. Set TOP: = TOP + 1. [Increases TOP by 1.]
3. Set STACK [TOP] : = ITEM. [Insert ITEM in new TOP position.]
POP (STACK, TOP, ITEM)
This procedure deletes the top element of the STACK and assigns it to the variable ITEM.
1. [Stack has an ITEM to be removed ?]
If TOP = 0, then: Print: UNDERFLOW, and Return.
2. Set ITEM : = STACK [TOP]. [Assingns TOP element to ITEM.]
3. Set TOP : = TOP -1. [Decreases TOP by 1. ]