logo CodeStepByStep logo

stackMystery1

Language/Type: C++ stack collections STL

What is the output of the following code?

stack s;
s.push(7);
s.push(10);
cout << s.top() << " ";
s.pop();
cout << s.top() << " ";
s.push(3);
s.push(5);
cout << s.top() << " ";
s.pop();
cout << s.size() << " ";
cout << s.top() << " ";
s.push(8);
cout << s.top() << " ";
s.pop();
cout << s.top() << " ";
output

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.