Tutorials

Stack


Stack Pop


When we delete the element from the top of the stack then it is known as pop operation.

 

stack pop by tutorialsinhand

 

Algorithm

stack[maxSize] is the stack.

item is the element to be deleted.

Algorithm given below deletes element from the top of the stack.

  1. Repeat steps 2 to 4 for if condition top >= 0
  2. set item = stack[top];
  3. set top = top - 1;
  4. Delete item and print item
  5. Else print "Stack underflow"

Stack Pop using C


//delete item from stack
void pop(){

   int item;

    if(top>=0){
    item = stack[top];
    top = top - 1;
    printf("Deleted item is %d", item);
    }else{
     printf("Stack is empty");
   }
}

 

 



Please Share this page
Views : 32
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!