#include
#include
using namespace std;
int main() {
int arr[] = {10, 20, 30, 40, 50}; // work in the sort arrays only
int n = sizeof(arr) / sizeof(arr[0]);
// Sort functions
// sort(arr, arr + n);
// for (int i = 0; i < n; i++) {
// cout << arr[i] << " ";
// }
// lower_bound and mainly used in the frequency count
auto it = lower_bound(arr, arr + n, 31);
cout << it - arr;
return 0;
}
why its returning the 40 index. I want to get the index of that element which is smaller and equal to 31