fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int ideone[5];
  7. int choice;
  8. int top = -1;
  9. int number;
  10. cout<<"1. Push an element"<<endl;
  11. cout<<"2. Pop an element"<<endl;
  12. cout<<"3. Exit"<<endl;
  13. cout<<" Enter your choice";
  14. cin>>choice;
  15.  
  16. switch(choice){
  17. case 1:
  18. cout<<"Push an Element";
  19. cin>>number;
  20. if(top > 4){
  21. cout<<"Array is full,No element can be pushed";
  22. }else{
  23. ideone[++top] =x;
  24. cout<<"Element Pushed";
  25. }
  26. break;
  27.  
  28. case 2:
  29. cout<<"Pop an Element";
  30. cin>>number;
  31. if(top = -1){
  32. cout<<"No element is present in array to be popped";
  33. }else{
  34. ideone[--top];
  35. cout<<"Element Popped";
  36. }
  37. break;
  38.  
  39. case 3:
  40. if(top = -1){
  41. cout<<"Array is empty";
  42. }else{
  43. for(int i=top; i>=0; i++){
  44. cout<<ideone[i]<<endl;
  45. }
  46. }
  47. break;
  48. }
  49.  
  50. return 0;
  51. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:23:19: error: ‘x’ was not declared in this scope
    ideone[++top] =x;
                   ^
stdout
Standard output is empty