stack operations in C++
Not what you're looking for?
What is the output from the following sequence of stack operations?
stack<int> intStack;
int x, y = 3;
intStack.push(8);
intStack.push(9);
intStack.push(y);
x = intStack.top();
intStack.pop();
intStack.push(18);
x = intStack.top();
intStack.pop();
intStackpush(22);
while (!intStack.empty())
{ y = intStack.top();
intStack.pop();
cout << y << " ";
}
cout << x << endl;
Please provide a complete program if it makes sense.
Purchase this Solution
Solution Summary
It finds the output from the sequence of stack operations. The response was rated '5/5' by the student who posted the question originally.
Purchase this Solution
Free BrainMass Quizzes
Word 2010: Tables
Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.
Javscript Basics
Quiz on basics of javascript programming language.
Word 2010: Table of Contents
Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.
Java loops
This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.
C# variables and classes
This quiz contains questions about C# classes and variables.