how the output is 6 ,the answer should be garbage value because the value in the lower bound is not present
Q.7 in STL quiz 1
Hello @harry_potter123,
Return Value: The function returns an iterator pointing to the element in the container which is equivalent to k passed in the parameter. In case k is not present in the set container, the function returns an iterator pointing to the immediate next element which is just greater than k. If the key passed in the parameter exceeds the maximum value in the container, then the iterator returned is equivalent to s.end() (A special iterator points beyond the last element).
And s.end() will return the number of elements int the set:
This is the reason it is returning 6.
Hope, this would help.
Give a like if you are satisfied.
so the number can be anything then??
Hello @harry_potter123,
Not anything.
As I have explained in my previous reply, it will print the number of elements in the set.