Take integer input from user and store it in the form of 1) stacks 2) queues and 3) Linked list.
#include <iostream>
#include <stack>
#include <queue>
#include <list>
using namespace std;
int main()
{
int x;
cout<<"Enter an integer : ";
cin>>x;
//stack
stack<int> s;
s.push(x);
cout<<"\nInteger stored in stack: "<<x;
//queue
queue<int> q;
q.push(x);
cout<<"\nInteger stored in queue: "<<x;
//linkedlist
list<int> l;
l.push_front(x);
cout<<"\nInteger stored in linked list: "<<x;
return 0;
}
Comments
Leave a comment