1.

What is the output of this program?
#include <iostream>
#include <list>
using namespace std;
int main ()
{
list<int> ListData;
list<int> :: iterator Iter1, Iter2;
for (int k = 0; k < 12; ++k) ListData.push_back(k * 2);
Iter1 = Iter2 = ListData.begin();
advance (Iter2, 7);
++Iter1;
Iter1 = ListData.erase (Iter1);
Iter2 = ListData.erase (Iter2);
++Iter1;
--Iter2;
ListData.erase (Iter1, Iter2);
for (Iter1 = ListData.begin(); Iter1 != ListData.end(); ++Iter1)
cout << ' ' << *Iter1;
return 0;
}

A. 22
B. 20 22
C. 18 20 22
D. 12 16 18 20 22
E. 0 4 12 16 18 20 22
Answer» F.


Discussion

No Comment Found

Related MCQs