Stacks Are Easy!

A stack is a very important data structure. Fortunately, the basic concepts are very simple.

A stack is a last in-first out data structure. There are two basic stack operations, push and pop. To push something on the stack is to add something to the top. To pop something off the stack is to remove the top element of the stack. Elements added to the stack are removed in reverse order.

Example:

push 10			Stack:	10

push 15			Stack:	15
				10

push 20			Stack:	20
				15
				10

pop			Stack:	15
				10

push 25			Stack: 	25
				15
				10

pop			Stack:	15
				10

pop			Stack:	10

pop			Stack:
An array is an easy way to implement a stack. You can write your own push and pop functions as well as a function to print the contents of the stack to the screen.

Example:

const int SIZE=5;
char array[SIZE];
int top=0;//index used to keep track of the top of the stack

'A' 'B'
--- --- --- --- ---
[0] [1] [2] [3] [4]

The illustration above shows the stack after 'A' and 'B'
have been pushed on the stack (read into the array).  Each time
a value is pushed on the stack, top is incremented.  (So top
is now 2.)

If we issue a pop command, top is decremented.  (So top is
now 1.)  The next value pushed will overwrite the 'B'.
Have fun! This problem is good array practice!