Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. int stack[10], top = -1;
  4. void push(int data)
  5. {
  6.     if(top>9)
  7.     {
  8.         printf("Stack is full\n");
  9.     }
  10.     stack[++top]=data;
  11.     printf("%d is pushed\n",data);
  12. }
  13. int pop()
  14. {
  15.     if(top<0)
  16.     {
  17.         printf("Stack is full\n");
  18.         return 0;
  19.     }
  20.     return stack[top--];
  21. }
  22.  
  23. int main()
  24. {
  25.     push(7);
  26.     push(11);
  27.     push(9);
  28.     printf("%d\n",pop());
  29.     printf("%d\n",pop());
  30.     printf("%d\n",pop());
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement