There is no element present at ‘it’ . So how 6?
How 6? There is no value at 'it'
What will be the output of the following C++ code? #include #include #include using namespace std; int main() { sets; s.insert(1); s.insert(5); s.insert(7); s.insert(2); s.insert(12); s.insert(10); auto it = s.lower_bound(15); cout<< *it <<endl; return 0;
@ashutosh_singh The lower_bound() method in C++ is used to return an iterator pointing to the first element in the range [first, last) which has a value not less than val. This means that the function returns the index of the next smallest number just greater than that number. since there is no element greater than 15 it just returns the index of last element + 1.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.