Stack Push

We can implement stack in two ways:

  1. Static implementation
  2. Dynamic implementation

Static implementation is done using arrays. As we are aware that size of the array has to be declared at the beginning so this process of stack implementation is not that flexible. 

Dynamic implementation is done using linked list and pointer.


Push Operation

When we insert element into the stack then this operation is known as Push operation.


stack push by tutorialsinhand



stack[maxSize] is the array implementation of stack.

top represents element at the topmost position in stack.


Given below is the algorithm for push operation in stack.

  1. Initialize top to -1
  2. Repeat step 3 to 5 for if condition top < maxSize -1
  3. Read and insert item
  4. Set top = top + 1;
  5. Set stack[top] = item;
  6. Else print "Stack overflow"

Stack push using C

//method for Push operation
void push(){

    int item;

    if(top < 3){
       printf("Enter the element");
       scanf("%d", &item);
       top = top + 1;
       stack[top] = item;
      printf("Stack overflow");



Please Share this page
Views : 74
Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!