implement stack using stack.h headerfile functions
Answer Posted / sv
#include <iostream>
#include <stack>
using namespace std;
int main()
{
string title;
int howmany;
stack<string> discs;
//Asking the user how many discs he wants to enter in the
stack.
//The loop will rotate that many number of times and then
//prompt the user for input.
cout<<"How many discs :";
cin>>howmany;
for(int i=0;i>title;
//pushing the discs one upon the other
discs.push(title);
}
cout<<"Now at the top of the CD Stack we have :"<<discs.top
()<<endl;
cout<<"The first one entered is "<<endl;
while(!discs.empty())
{
title = discs.top();
discs.pop();
}
cout<<title<<endl;
return 0;
}
| Is This Answer Correct ? | 4 Yes | 4 No |
Post New Answer View All Answers
How do you decide which integer type to use?
Which sort does c++ use?
How a new operator differs from the operator new?
What is virtual destructor ans explain its use?
In int main(int argc, char *argv[]) what is argv[0] a) The first argument passed into the program b) The program name c) You can't define main like that
What is c++ manipulator?
What is array in c++ pdf?
What are the advantages of using const reference arguments in a function?
What is runtime errors c++?
What is the fastest c++ compiler?
What is virtual table?
How a modifier is similar to mutator?
What is jump statement in C++?
What is a stack? How it can be implemented?
What is the purpose of extern storage specifier?