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

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


Please Help Members By Posting Answers For Below Questions

What header file is needed for exit(); a) stdlib.h b) conio.h c) dos.h

395


What is a forward referencing and when should it be used?

370


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create

1840


Can notepad ++ run c++?

347


What is binary search in c++?

335






Why is c++ not purely object oriented?

330


Can a constructor return a value?

343


What do the keywords volatile and mean mutable?

381


What are the benefits of c++?

333


How the programmer of a class should decide whether to declare member function or a friend function?

408


Where is atoi defined?

356


How do you find out if a linked-list has an end?

412


How do you flush std cout?

343


What is a friend function in c++?

366


Explain the volatile and mutable keywords.

393