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
What header file is needed for exit(); a) stdlib.h b) conio.h c) dos.h
What is a forward referencing and when should it be used?
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create
Can notepad ++ run c++?
What is binary search in c++?
Why is c++ not purely object oriented?
Can a constructor return a value?
What do the keywords volatile and mean mutable?
What are the benefits of c++?
How the programmer of a class should decide whether to declare member function or a friend function?
Where is atoi defined?
How do you find out if a linked-list has an end?
How do you flush std cout?
What is a friend function in c++?
Explain the volatile and mutable keywords.