Stack in C

Prev Tutorial Next Tutorial

Stack in C

Stack is linear data structure. In stack addition of new data item and deletion of already existing data item is done from only one end, known as top. Working of stack on the basis of Last-in-First-out (LIFO) principal, it means last entered item remove first.


Working of Stack in C

A stack is a container of objects that are inserted and removed according to the Last-in First-Out (LIFO) principle. Both operation insert and deletion perform in stack only from TOP.

Real life example of stack

A most popular example of stack is plates in marriage party. Fresh plates are pushed onto to the top and popped from the top.

stack real life example

Stack Operation

In stack data structure mainly perform two operation; push and pop

  • pop: In case of stack deletion of any item from stack is called pop.
  • push: In case of stack Insertion of any item in stack is called push.

Use of stack

  • Expression evaluation
  • Backtracking (game playing, finding paths, exhaustive searching)
  • Memory management, run-time environment for nested language features.
  • To reverse a word. You push a given word to stack - letter by letter - and then pop letters from the stack.
  • An "undo" mechanism in text editors; this operation is accomplished by keeping all text changes in a stack.
  • space for parameters and local variables is created internally using a stack.
  • compiler's syntax check for matching braces is implemented by using stack.
  • Back/Forward on browsers are perform using stacks.

Prev Tutorial Next Tutorial

Download Projects

Google Adsense Advertisements
Free Classified Site – Bedpage

Yahoo Advertisements