Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Do you know what are the new features that iso/ansi c++ has added to original c++ specifications?

1185


Why cstdlib is used in c++?

1092


If a function doesn’t return a value, how do you declare the function?

1106


What do you understand by pure virtual function? Write about its use?

1044


What is a singleton class c++?

1090


Which function cannot be overloaded c++?

1161


How should a contructor handle a failure?

1235


Explain the use of virtual destructor?

1121


What is encapsulation in c++ with example?

1041


When to use “const” reference arguments in a function?

1120


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

1208


what does the following statement mean? int (*a)[4]

1136


Is c++ a programming language?

1136


What is stack unwinding?

1204


Why c++ is so important?

1137