Answer to Question #199722 in C++ for Ayesha

Question #199722

Take user input and insert the data at the respective position in the sorted 1) stack 2) queue and 3) linked list.


1
Expert's answer
2021-05-27T19:08:40-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