🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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;
}
  1. A.12
  2. B.22
  3. C.48
  4. 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 →