Stack is a special kind of linear list. Linear list is an ordered collection of a number of items of the same type. Two operations are performed frequently from linear list – insertion and deletion. A stack is a linear list where all insertions and deletions happen at one end of the list. A stack is often called Last In First Out(LIFO) because a first element removed is the last element pushed to the stack.

Here we will see the operations on stack using linked list because the stack is never full as long as the system has enough space for dynamic memory allocation.

A stack can defined by following structure:

If stack variable is s then s->top points to the top of the stack s. Push and pop operations on such a stack will involve manipulation of this top pointer.

The complete source code is given below

When you run the above code you will see the below output

Thanks for reading.

Software Professional, I am passionate to work on web/enterprise application. For more information please go to about me. You can follow on Twitter. You can be a friend on Facebook or Google Plus or Linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.