void display() { if(top>=0) { cout<<"Stack elements are:"; for(int i=top; i>=0; i--) cout<<stack[i]<<" "; cout<<endl; }else cout<<"Stack is empty"; }