Similar Problems not available
In C++, the standard library gives us the facility to use the Stacks as a type of container adaptors with LIFO type of working. The stack::pop() is a C++ Standard Library function which is used to remove an element from the top of the stack. After removing the element to the stack container the size decreased by 1.
Stack_Name.pop( );
Parameter: The stack::pop() function does not accepts any parameter.
Return value: The stack::pop() function does not returns any value.
#include <iostream>
#include <stack>
using namespace std;
int main()
{
stack<int> STK;
STK.push(10);
STK.push(20);
STK.push(30);
while (!STK.empty())
{
cout << STK.top() << ' ';
STK.pop();
}
}
30 20 10