Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <iterator>
    #include <list>
    using namespace std;
    int main ()
    {
    list<int> List1, List2;
    for (int k = 0; k <= 3; k++)
    {
    List1.push_back(k);
    List2.push_back(k * 12);
    }
    list<int> :: iterator Iter;
    Iter = List1.begin();
    advance (Iter, 3);
    copy (List2.begin(), List2.end(), inserter(List1, Iter));
    for ( Iter = List1.begin(); Iter != List1.end(); ++Iter )
    cout << *Iter << " ";
    return 0;
    }
    1. 0 1 2 0 12
    2. Compilation Error
    3. 0 1 2 0 12 24 36 3
    4. 24 36 3
    5. None of these
Correct Option: C

In this iterator, We are copying the first list into second and printing it.



Your comments will be displayed only after manual approval.