🎙 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 1 of 10

What does this print? (code)

What does this print?

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    vector<int> v = {1, 3, 3, 5, 7};
    cout << lower_bound(v.begin(), v.end(), 3) - v.begin();
    return 0;
}
  1. A.2
  2. B.1
  3. C.3
  4. D.0
Answer & explanation

Correct answer: 1

lower_bound finds the first element >= 3, at index 1.

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 →