fork download
  1. #include <stdio.h>
  2. void Push(int *,int *);
  3. void Pop(int *);
  4. void Print(int *,int *);
  5.  
  6. int main(void) {
  7.  
  8. int A[10];
  9. int top=-1;
  10. scanf("%d",&top);
  11. Push(A,&top);
  12. Push(A,&top);
  13. Push(A,&top);
  14. Print(A,&top);
  15. Pop(&top);
  16. Print(A,&top);
  17. scanf("%d",&top);
  18. return 0;
  19. }
  20.  
  21.  
  22. void Push(int *a,int *top){
  23. if(*top>=10){
  24. printf("Stack is Full");
  25. return;
  26. }
  27. int val;
  28. printf("Enter data");
  29. scanf("%d",&val);
  30. a[++(*top)]=val;
  31.  
  32. }
  33.  
  34. void Pop(int *top){
  35. if(*top==-1){
  36. printf("The list is Empty");
  37. }
  38. *top--;
  39. }
  40.  
  41. void Print(int* a,int *top){
  42. if(*top==-1)
  43. {
  44. printf("The stack is empty");
  45. }
  46. for(int i=0;i<=(*top);i++)
  47. {
  48. printf("%d",*top);
  49. }
  50. }
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
Enter dataEnter dataEnter data222222