Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <deque>
    using namespace std;
    int main ()
    {
    unsigned int k;
    deque<int> FirstDeque (4,125);
    deque<int> SecondDeque (5,150);
    FirstDeque.swap(SecondDeque);
    cout << "First Data contains:";
    for (deque<int>::iterator iter = FirstDeque.begin(); iter != FirstDeque.end(); ++iter)
    cout << ' ' << *iter;
    cout << "\nSecond Data contains:";
    for (deque<int>::iterator iter = SecondDeque.begin(); iter != SecondDeque.end(); ++iter)
    cout << ' ' << *iter;
    return 0;
    }
    1. Second Data contains: 125 125 125 125
    2. Second Data contains: 125 125 125 125
      First Data contains: 150 150 150 150 150
    3. First Data contains: 150 150 150 150 150
    4. First Data contains: 150 150 150 150 150
      Second Data contains: 125 125 125 125
    5. None of these
Correct Option: B

In this program, We swapped the values of both dequeues and printing the dequeues.



Your comments will be displayed only after manual approval.