Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- int stack[10], top = -1;
- void push(int data)
- {
- if(top>9)
- {
- printf("Stack is full\n");
- }
- stack[++top]=data;
- printf("%d is pushed\n",data);
- }
- int pop()
- {
- if(top<0)
- {
- printf("Stack is full\n");
- return 0;
- }
- return stack[top--];
- }
- int main()
- {
- push(7);
- push(11);
- push(9);
- printf("%d\n",pop());
- printf("%d\n",pop());
- printf("%d\n",pop());
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement