set stl Question 5

Last Updated :
Discuss
Comments

What will be the output of the following C++ code?

#include <bits/stdc++.h>
using namespace std;
int main()
{
int arr[] = { 14, 12, 15, 11, 10 };

set<int> s(arr, arr + 5);
for (auto it = s.cbegin(); it != s.cend(); it++)
 cout << *it << " ";
return 0;
}

10 11 12 14 15

12 14 15

15 14 13 12 11

 13 12 11

Share your thoughts in the comments