implement stack using stack.h headerfile functions
Answer / 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 |
Write a recursive program to calculate factorial in c++.
What is the use of static functions?
Can the operator == be overloaded for comparing two arrays consisting of characters by using string comparison?
What is dangling pointers?and what is memory leak?
Why is c++ still popular?
what are function pointers?
The "virtual" specifier in a member function enables which one of the following? a) Monmorphism b) Late binding c) Metamorphism d) Solomorphism e) Inheritance
How many types of comments are there in c++?
What are c++ data types?
What is difference between initialization and assignment?
12 Answers HCL, HP, Infosys,
How do you clear a set in c++?
what does the following statement mean? int (*a)[4]