Computer Science Homework Solutions
Problem
#133453

Data Structures with C++ Using STL

What is the output from the following sequence of stack operations?

stack 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.

Solution
What is this?
By OTA - Overall OTA Rating
Yanfang Li, PhD - 4.9/5
Purchase Cost Now
$2.19 CAD (was ~$11.97)
Included in Download
  • Plain text response
  • Attached file(s):
    • project1.zip
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
Browse