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
Explain about Garbage Collector?
How can you quickly find the number of elements stored in a dynamic array? Why is it difficult to store linked list in an array?
Explain the term memory alignment?
What is a container class? What are the types of container classes in c++?
Explain pass by value and pass by reference.
What is fflush c++?
What's the most powerful programming language?
What are guid?
What is #include math h in c++?
What relational operators if statements in c++?
What is & in c++ function?
Can I learn c++ in a week?
write a function signature with various number of parameters.
What are the sizes and ranges of the basic c++ data types?
find the two largest values among the 6 numbers using control structures : do-while,for,if else,nestedif- else ,while. one or two of them.