Last Updated : 10 Apr, 2024
vector <int> vec = {2, 2, 2, 5, 5, 6, 6, 7, 7, 8};
    vector<int> :: iterator lo;
    lo = lower_bound(vec.begin(), vec.end(), 4);
    cout << (lo - vec.begin())<< \" \" << *lo;

Predict the output for the above code snippet of the program
(A) 5 5
(B) 3 5
(C) 5 3
(D) None of the mentioned


Answer: (B)

Explanation:
lo – vec.begin(): returns the iterator to the first element which has a value not less than 4.
*lo – returns the element which is not less than 4 i.e. 5.


Share your thoughts in the comments