Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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

write the prime no program in c++?

16 Answers  


What is the use of volatile keyword in c++? Give an example.

1 Answers  


What is the disadvantage of using a macro?

0 Answers  


When to use Multiple Inheritance?

6 Answers  


#include<iostream.h> void main() { class x { public: int func(int) { cout<<"cool"; return 1; } } }

1 Answers   Infosys,






What is function overloading c++?

0 Answers  


What is the difference between an external iterator and an internal iterator?

0 Answers  


How would you use the functions sin(), pow(), sqrt()?

0 Answers  


Why is polymorphism useful?

0 Answers  


How many pointers are required to reverse a link list?

5 Answers   CTS,


What is a modifier in c++?

0 Answers  


If there are 1 to 100 Numbers in array of 101 elements. Which is the easy way to find repeated number?

2 Answers   Persistent,






Categories