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> DataList;
    for (int k = 0; k < 8; k++)
    DataList.push_back (k * 8);
    list<int> :: iterator Iter = DataList.begin();
    advance (Iter, 6);
    cout << *Iter << endl;
    return 0;
    }
    1. Compilation Error
    2. 8
    3. Runtime Error
    4. 48
    5. None of these
Correct Option: D

In this program, We are printing the sixth element in the list.



Your comments will be displayed only after manual approval.