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 many characters are recognized by ANSI C++?
What is null and void pointer?
What is math h in c++?
Using a smart pointer can we iterate through a container?
What is iomanip c++?
What is the difference between passing by reference and passing a reference?
Do you know the use of vtable?
What are structures and unions?
What is type of 'this' pointer?
What is the standard template library (stl)?
To which numbering system can the binary number 1101100100111100 be easily converted to?
Explain the uses of static class data?
What is the use of turbo c++?
What is vectorial capacity?
Is turbo c++ free?