Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #define size 6
- 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(value)
- {
- if(sFull())
- printf("overflow");
- else
- {
- top++;
- s[top]=value;
- }
- }
- void pop()
- {
- if(sEmpty())
- printf("Underflow");
- else
- {
- top--;
- }
- }
- void display()
- {
- int i;
- if(top==-1)
- {
- printf("\nStack is empty...");
- }
- else
- {
- for(i=top;i>=0;--i)
- printf("%d\n",s[i]);
- }
- }
- int main()
- {
- push(16);
- push(7);
- push(5);
- pop();
- display();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement