← Quiz: STL Algorithms: all 10 questions
Quiz: STL Algorithms · Question 3 of 10
What does this print? (code)
What does this print?
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
int main() {
vector<int> v = {2, 4, 6};
cout << accumulate(v.begin(), v.end(), 10);
return 0;
}
- A.12
- B.22
- C.48
- D.10
Answer & explanation
Correct answer: 22
The start value 10 plus 2 + 4 + 6 = 22.
Can you get the rest right without peeking?
Take the timed Quiz: STL Algorithms quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →