What is the output int arr[5] = { 4, 5, 1, 0, 1 }; sort( arr, arr+5 ); cout<< lower_bound( arr, arr+5, 3 ) - arr <<endl;

int arr[5] = { 4, 5, 1, 0, 1 };
sort( arr, arr+5 );
cout<< lower_bound( arr, arr+5, 3 ) - arr <<endl;

@khanmahboob8877 the output is 3.
lower_bound returns an iterator to the lower bound element that value - arr gives us the index of that iterator because arr stores the base address.

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.