fork(1) download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int max;
  5. int stack[10];
  6. int num,i,temp;
  7. int top = -1;
  8. //printf("Enter the maximum size of stack");
  9. scanf("%d",&max);
  10. //printf("Enter the no of elements in stack");
  11. scanf("%d",&num);
  12. //printf("Enter the elements of stack");
  13. for(i=0;i<num;i++)
  14. {
  15. scanf("%d\n",&stack[i]);
  16. top++;
  17. }
  18. temp =top;
  19. if(top == -1)
  20. {
  21. printf("Underflow");
  22. }
  23. else
  24. {
  25. top =top -1;
  26. printf("The stack after pop operation is \n");
  27. for(i=top;i>=0;i--)
  28. {
  29. printf("%d\n",stack[i]);
  30. top--;
  31. }
  32. }
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0s 2252KB
stdin
4
4

1
2
3
4
stdout
The stack after pop operation is 
3
2
1