write a program in c++ to implement stack using functions
in header file stack.h

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 ?    31 Yes 29 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by friend class & friend function in c++?

804


What are c++ manipulators?

806


Does dev c++ support c++ 11?

748


Define a pdb file.

824


What are maps in c++?

705


Explain the virtual inheritance in c++.

800


What are member functions used in c++?

774


Which ide is best for c++?

754


What is the difference between a pointer and a link in c ++?

768


What are the uses of c++ in the real world?

768


What is a syntax in c++?

859


List the features of oops in c++?

762


What is the difference between set and map in c++?

866


What is purpose of abstract class?

782


How many types of scopes are there in c++?

783