Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int top=-1, arr[100];
- void push(int n)
- {
- if(top>=100)
- {
- printf("Stack is overflown.\n");
- return;
- }
- else
- arr[++top]=n;
- }
- int pop()
- {
- if(top==-1)
- {
- printf("Stack is empty.\n");
- return -1;
- }
- else
- arr[top--];
- }
- int main()
- {
- int i,n,x,s;
- scanf("%d", &n);
- for(i=0; i<n; i++)
- {
- scanf("%d", &x);
- push(x);
- }
- while(n--)
- {
- printf("%d ", arr[top]);
- pop();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement