Basic Concept of Stack



Basic Concept of Stack : C Data Structure

Stack Operation in C Programming

Definition :

[box]Stack is first in last out Structure (LIFO) Structure .[/box]

Explanation : 

Stack is Data Structure used to store the data in such a way that element inserted into the stack will be removed at last.

Just take real time example, Suppose we have created stack of the book like this shown in the following fig –

Stack Concept

Stack Concept

How Books are arranged in Stack ? :

  1. Books are kept one above the other
  2. Book which is inserted first is Taken out at last.(Brown)
  3. Book which is inserted Lastly is served first.(Light Green)

Common Example :

Suppose at your home you have multiple chairs then you put them together to form a vertical pile. From that vertical pile the chair which is placed last is always removed first.
Chairs Stack
Chair which was placed first is removed last. In this way we can see how stack is related to us. We are implementing the stack using C Programming in the upcoming chapters.
Image source : Link