-
What is the output of this program?
#include <iostream>
#include <iterator>
#include <list>
using namespace std;
int main ()
{
list<int> DataList;
for (int i = 0; i < 10; i++)
DataList.push_back (i * 30);
list<int> :: iterator firstIter = DataList.begin();
list<int> :: iterator lastIter = DataList.end();
cout << distance(firstIter, lastIter) << endl;
return 0;
}
-
- 10
- 30
- Compilation Error
- All of above
- None of these
Correct Option: B
In this program, We are printing the number of elements in the list by using distance method.