Answer to Question #200242 in C++ for Kinza

Question #200242

Take integer input from user and store it in the form of 1) stacks 2) queues and 3) Linked list.




1
Expert's answer
2021-05-29T03:35:10-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog