Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <set>
    using namespace std;
    int main()
    {
    set<int> DataSet;
    DataSet.insert(25);
    DataSet.insert(20);
    DataSet.insert(30);
    DataSet.insert(35);
    DataSet.insert(18);
    set<int> :: const_iterator p;
    for(p = DataSet.begin(); p != DataSet.end(); ++p)
    cout << *p << ' ';
    return 0;
    }
    1. 18
    2. 18 20
    3. 18 20 25
    4. 18 20 25 30
    5. 18 20 25 30 35
Correct Option: E

In this program, We are using const_iterator to sort the data



Your comments will be displayed only after manual approval.