0

what is the output of this program??

#include<iostream> #include<stack> using namespace std; int main() { stack<int> s; s.push(1); s.push(2); s.empty(); s.push(3); cout<< s.size(); }

5th May 2020, 2:32 PM
Apeksha Malvi
2 Answers
0
The output is 3. If you're asking WHY it outputs 3, the empty function does not empty the stack; it return 1 if it's empty and 0 if it's not. Thus, after pushing 3 numbers into the stack, the size of the stack is 3 and outputs 3.
5th May 2020, 2:44 PM
CeePlusPlus
CeePlusPlus - avatar