Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <set>
    using namespace std;
    int main ()
    {
    multiset<int> MultisetData;
    for (int k = 0; k < 6; k++) MultisetData.insert(k);
    multiset :: key_compare compare = MultisetData.key_comp();
    int highest = *MultisetData.rbegin();
    multiset :: iterator Iter = MultisetData.begin();
    do
    {
    cout << ' ' << *Iter;
    } while (compare(*Iter++, highest));
    return 0;
    }
    1. 0 1 2 3 4 5
    2. 0 1 2 3 4
    3. 0 1 2 3
    4. 0 1 2
    5. 0 1
Correct Option: A

In this program, We used the set template and then we compared the keys and printing the result.



Your comments will be displayed only after manual approval.