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> SetData;
    SetData.insert(25);
    SetData.insert(15);
    SetData.insert(45);
    SetData.insert(35);
    SetData.insert(55);
    while (!SetData.empty())
    {
    cout << ' ' << *SetData.begin();
    SetData.erase(SetData.begin());
    }
    return 0;
    }
    1. 15
    2. 15 25
    3. 15 25 35
    4. 15 25 35 45
    5. 15 25 35 45 55
Correct Option: E

In this program, We used the set template and then we are initializing the values and then we are erasing it.



Your comments will be displayed only after manual approval.