-
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;
}
-
- 22
- 20 22
- 18 20 22
- 12 16 18 20 22
- 0 4 12 16 18 20 22
Correct Option: E
In this program, We are comparing the values in both lists and erasing it according to certain condition.