getting wrong ans from the codechef ide

while using the the // function lowerbound ,i am geting output as 21…which is something i did not expect…

my code…

int main()
{
	
	int arr1[] = {10, 15, 20, 25, 30, 35};
	
	printf("%d",lower_bound(arr1, arr1+24,10) - arr1);
    return 0;
}

help please-:slight_smile:

Read about lower bound here.

Throws if either an element comparison or an operation on an iterator throws.
Note that invalid arguments cause undefined behavior.

Your array size isnt 24, so “arr+24” isnt a valid argument. Replace it with “arr+6” and report the result to us ^^

thanks its correct…got my mistake…:slight_smile:

Glad that it helped dear ^^