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

Why are pointers not used in c++?

626


an integer constant must have atleast one a) character b) digit c) decimal point

554


What are namespaces in c++?

589


What is the syntax for a for loop?

594


What is the full form nasa?

595






Is c++ a programming language?

592


What do you mean by stack unwinding in c++?

725


What is the output of the following program? Why?

620


What kind of jobs can I get with c++?

591


What is the use of setprecision in c++?

540


What is the main use of c++?

547


Why main function is special in c++?

665


Does c++ cost money?

578


Is c++ used anymore?

585


Is c++ a software?

724