fork download
  1. #include<iostream>
  2. #include<conio.h>
  3. #include<stdlib.h>
  4. using namespace std;
  5. class stack
  6. {
  7. int stk[5];
  8. int top;
  9. public:
  10. stack()
  11. {
  12. top=-1;
  13. }
  14. void push(int x)
  15. {
  16. if(top > 4)
  17. {
  18. cout <<"stack over flow";
  19. return;
  20. }
  21. stk[++top]=x;
  22. cout <<"inserted" <<x;
  23. }
  24. void pop()
  25. {
  26. if(top <0)
  27. {
  28. cout <<"stack under flow";
  29. return;
  30. }
  31. cout <<"deleted" <<stk[top--];
  32. }
  33. void display()
  34. {
  35. if(top<0)
  36. {
  37. cout <<" stack empty";
  38. return;
  39. }
  40. for(int i=top;i>=0;i--)
  41. cout <<stk[i] <<" ";
  42. }
  43. };
  44.  
  45. main()
  46. {
  47. int ch;
  48. stack st;
  49. while(1)
  50. {
  51. cout <<"\n1.push 2.pop 3.display 4.exit\nEnter ur choice";
  52. cin >> ch;
  53. switch(ch)
  54. {
  55. case 1: cout <<"enter the element";
  56. cin >> ch;
  57. st.push(ch);
  58. break;
  59. case 2: st.pop(); break;
  60. case 3: st.display();break;
  61. case 4: exit(0);
  62. }
  63. }
  64. return (0);
  65. }
Compilation error #stdin compilation error #stdout 0s 16048KB
stdin
Standard input is empty
compilation info
prog.cpp:2:18: fatal error: conio.h: No such file or directory
 #include<conio.h>
                  ^
compilation terminated.
stdout
Standard output is empty