Push pop operation using stack in C

What is stack in C programming?

The stack is one kind of data structure in which you can push something and pop them reverse order. So the last added item is the first item we can remove. This is also called LIFO (last in first out) operation.
When we add items in stock, it's called push operation. When we remove the item from the stack, is called pop operation.
Hope the following example make this clear :
Push and Pop operation

Push and pop operation in C language

Push operation :

Initially item = 0. If you push item, item become item++ . So after pushing item, you have to check.If item = = size, show warning. Else scan item and push into the stack. Then increase item by 1 . 

Pop operation :

After pop item from stack, you have to check is there any item in the stack ? If item = = 0, show warning that "Underflow" means stack is empty. Else decrease item by 1. Print popes item.

Full push and pop operation:

Happy coding.......

Related post :

Function Calling in C       Linked List Operations algorithm          Some star pattern coding in C

0/Post a Comment/Comments