implement stack using stack.h headerfile functions
Answer / 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 |
What is the return value of the insertion operator?
What is virtual function? Explain with an example
Can we specify variable field width in a scanf() format string? If possible how?
Does dev c++ support c++ 11?
Explain public, protected, private in c++?
Does std endl flush?
What do the header files usually contains?
What is the use of this pointer in c++?
What is the advantage of an external iterator.
In java a final class is a class that cannot be derived. How can you make a similar class in C++
Why use of template is better than a base class?
what is pulse code modulation?