implement stack using stack.h headerfile functions



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

Post New Answer

More C++ General Interview Questions

Do you know the use of vtable?

0 Answers  


How do I write a c++ program?

0 Answers  


what is C++ objects?

0 Answers  


How many pointers are required to reverse a link list?

5 Answers   CTS,


Where is atoi defined?

0 Answers  






What is the role of C++ shorthand's?

0 Answers   TCS,


Mention the storage classes in c++.

0 Answers  


What is malloc in c++?

0 Answers  


What is a mutable member?

1 Answers  


Difference between a homogeneous and a heterogeneous container

0 Answers  


How do pointers work?

0 Answers  


Is swift faster than c++?

0 Answers  


Categories