0% found this document useful (0 votes)
6 views1 page

C++ Stack Implementation Guide

This C++ program implements a stack using the STL stack container. It provides a menu for users to insert elements, delete elements, check the size, and view the top element of the stack. The main function contains a switch statement inside a while loop to process the user's menu selection and perform the corresponding stack operation.

Uploaded by

tapas_bayen9388
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

C++ Stack Implementation Guide

This C++ program implements a stack using the STL stack container. It provides a menu for users to insert elements, delete elements, check the size, and view the top element of the stack. The main function contains a switch statement inside a while loop to process the user's menu selection and perform the corresponding stack operation.

Uploaded by

tapas_bayen9388
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Implementation:

#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>
using namespace std;
int main()
{
stack<int> st;
int choice, item;
while (1)
{
cout<<"\n---------------------"<<endl;
cout<<"Stack Implementation in Stl"<<endl;
cout<<"\n---------------------"<<endl;
cout<<"[Link] Element into the Stack"<<endl;
cout<<"[Link] Element from the Stack"<<endl;
cout<<"[Link] of the Stack"<<endl;
cout<<"[Link] Element of the Stack"<<endl;
cout<<"[Link]"<<endl;
cout<<"Enter your Choice: ";
cin>>choice;
switch(choice)
{
case 1:
cout<<"Enter value to be inserted: ";
cin>>item;
[Link](item);
break;
case 2:
item = [Link]();
[Link]();
cout<<"Element "<<item<<" Deleted"<<endl;
break;
case 3:
cout<<"Size of the Stack: ";
cout<<[Link]()<<endl;
break;
case 4:
cout<<"Top Element of the Stack: ";
cout<<[Link]()<<endl;
break;
case 5:
exit(1);
break;
default:
cout<<"Wrong Choice"<<endl;
}
}
return 0;
}

You might also like