← Quiz: STL Containers: all 9 questions
Quiz: STL Containers · Question 2 of 9
What does this print? (code)
What does this print?
#include <iostream>
#include <set>
using namespace std;
int main() {
set<int> s = {3, 1, 3, 2, 1};
cout << s.size();
return 0;
}
- A.5
- B.3
- C.2
- D.1
Answer & explanation
Correct answer: 3
A set keeps unique values: {1, 2, 3}.
Can you get the rest right without peeking?
Take the timed Quiz: STL Containers quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →