Professional Documents
Culture Documents
#include <iostream>
#include <stack>
int main ()
stack<int>s1;
s1.push(10);
s1.push(20);
stack<int> s;
s.push(2);
s.push(3);
s.push(4);
s.pop();
swap(s,s1);
while(!s.empty())
cout<<s.top()<<endl;
s.pop();
while(!s1.empty())
cout<<s1.top()<<endl;
s1.pop();
PROGRAM 2
#include <iostream>
#include <stack>
int main()
stack<int> nStack;
nStack.push(1);
nStack.push(2);
stack<int> nStack1;
nStack1.push(3);
nStack1.push(4);
//nStack.swap(nStack1);
while(!nStack.empty())
{
cout<<nStack.top()<<endl;
nStack.pop();
cout<<"After Popping"<<endl;
nStack.pop();
return 0;