Expt 4 Printout
Expt 4 Printout
void display() {
cout<< “Stack:”;
for(int I =0; i<=top; i++){
cout<< arr[i] << “ ”;
}
cout<<endl;
}
};
int main(){
Stack s(3);
s.push(10);
s.push(20);
s.push(30);
s.display();
s.pop();
s.display();
return 0;
}
OUTPUT:
Element 10 is pushed.
Element 10 is pushed.
Element 10 is pushed.
Element 10 is pushed.
Stack: 10 20 30
Element 30 is popped.
Stack: 10 20