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

How do you clear a buffer in c++?

963


Is c++ a dying language?

1154


What is const pointer and const reference?

1166


Differentiate between an external iterator and an internal iterator? What is the advantage of an external iterator.

1044


What is the difference between public, private, and protected access?

1070


How a new element can be added or pushed in a stack?

1020


What is #include c++?

1136


What is c strings syntax?

1146


Why is polymorphism useful?

1076


What is time h in c++?

1139


Which is better c++ or java?

984


What is purpose of abstract class?

1074


What does catch(…) mean?

1119


Can we define a constructor as virtual in c++?

1129


What is private, public and protected inheritance?

1090