(it-arr) at 3:34

since lower_bound() returns address of the first occurrence here so how it-arr where arr is the address of the starting element of the array then shouldn’t it be 2×size of int rather than just 2

hello @a.amanbhardwaj6

pointer arithmetic is bit different than normal arithmetic operations.
for example
if ptr is pointer to int and pointing to address 100 . then
ptr+1 will not be 101 ,it will be ptr + sizeof(int) * 1.

similar is the case with subtration
when we do ptr2-ptr1 then
it is equal to (ptr2-ptr1)/sizeof(int) // if both pointer is pointing to int datatype.

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.