diff --git a/Stack b/Stack new file mode 100644 index 0000000..a049c53 --- /dev/null +++ b/Stack @@ -0,0 +1,38 @@ +// Stacks are a type of container adaptors with LIFO(Last In First Out) type of working, +// where a new element is added at one end and (top) an element is removed from that end only + +#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; +}