Skip to content

Latest commit

 

History

History
37 lines (30 loc) · 532 Bytes

third.md

File metadata and controls

37 lines (30 loc) · 532 Bytes

// CPP program to demonstrate working of STL stack #include #include using namespace std;

void showstack(stack s) { while (!s.empty()) { cout << '\t' << s.top(); s.pop(); } cout << '\n'; }

int main () { stack s; s.push(10); s.push(30); s.push(20); s.push(5); s.push(1);

cout << "The stack is : "; 
showstack(s); 

cout << "\ns.size() : " << s.size(); 
cout << "\ns.top() : " << s.top(); 


cout << "\ns.pop() : "; 
s.pop(); 
showstack(s); 

return 0; 

}