Guest User

Untitled

a guest
Mar 21st, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #include<stdio.h>
  2. using namespace std;
  3. int stack[10];
  4. int k=-1;
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12. void push(int n){
  13. k++;
  14. stack[k]=n;
  15. }
  16.  
  17. int pop(){
  18. return stack[k--];
  19.  
  20.  
  21. }
  22. isEmpty(){
  23. if(k==-1)
  24. printf("Empty");
  25. else
  26. printf("Not Empty");
  27.  
  28. }
  29.  
  30. int main(){
  31.  
  32.  
  33. push(20);
  34. push(10);
  35. push(42);
  36.  
  37. pop();
  38. pop();
  39.  
  40. pop();
  41. isEmpty();
  42.  
  43. return 0;
  44.  
  45.  
  46. }
Add Comment
Please, Sign In to add comment