Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #define size 10
- int s[size], top=-1;
- int sfull()
- {
- if(top==size-1) return 1;
- return 0;
- }
- int sempty()
- {
- if(top==-1) return 1;
- return 0;
- }
- void push(int item){
- if(sfull()) printf("Overflow\n");
- else{
- ++top;
- s[top]=item;
- }
- }
- void pop()
- {
- if(sempty()) printf("Underflow\n");
- else{
- top--;
- }
- }
- void display()
- {
- for(int i=top; i>=0; i--) printf("%d ",s[i]);
- }
- int main()
- {
- push(5);
- push(10);
- push(15);
- push(20);
- push(25);
- display();
- pop();
- pop();
- printf("\n");
- display();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement