C Stack

A stack is just the opposite of a queue. Since Stack uses last-in, first-out accessing, that is also known as LIFO.

To visualize a stack, just imagine a stack of plates. The first plate on the table is the last to be used, and the last plate placed on the stack
is the first to be used. Stacks are used frequently in system software, including compilers and interpreters.

When working with stacks, the two basic operations i.e., store and review are traditionally called as push and pop respectively.
Therefore, to implement a stack, you need two functions (one responsible for storing and the other one responsible for reviewing) i.e.,
the push() function (places a value on the stack) and the pop() function (retrieves a value from the stack). You also need a region
of memory to use as stack. You can use an array for this purpose or allocate a region of memory using
dynamic allocation functions of C.
As with the queue, the retrieval function takes a value off the list and destroys it if it is not stored elsewhere.
The general form of push() and pop() that use an integer array follow. You can maintain the stacks of other data types by
changing the base type of array on which the push() and the pop() function operate.

Here, the variable top is the index of the top of stack. When implementing these functions, you must remember to prevent the
overflow and underflow of stack. In these routines, an empty stack is signalled by top being zero and a full stack by top
being greater than last storage location.