Answer to Question #95712 in C++ for matimu

Question #95712
using deque ( double ended queue) standard template library. develop a program that uses the keyword push_back to add element at the end and push_front to insert element at beginning.
the program should then list the size of the deque.
1
Expert's answer
2019-10-03T05:18:31-0400
#include <deque> // std::deque<>
#include <iostream> // std::cout, std::endl

int main()
{
    // Create a deque (double ended queue)
    std::deque<int> deq;

    // Use the keyword push_back to add element at the end
    int element1 = 10;
    deq.push_back(element1);

    // Use the keyword push_front to insert element at beginning
    int element2 = -101;
    deq.push_front(element2);

    // Output the size of the deque
    std::cout << deq.size() << std::endl;
}

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
APPROVED BY CLIENTS