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 |
What is function declaration in c++ with example?
Explain virtual class and friend class.
"How will you merge these two arrays? Write the program Array: A 1 18 22 43 Array: B 3 4 6 20 34 46 55 Output Array: C 1 3 4 6 18 20 22 34 43 46 55"
9 Answers College School Exams Tests, HCL,
What is class definition in c++ ?
What are different types of typecasting supported by C++
Describe the process of creation and destruction of a derived class object?
Who created c++?
How do you decide which integer type to use?
What are the different types of comments allowed in c++?
What will happen if a pointer is deleted twice?
Shall we use 'free' to free memory assigned by new, What are the further consequences??
What are c++ files?