How pointer value is stored in int

when i am subtracting
int lb= lower_bound(arr,arr+n,6)-arr;
how can I store this value in int since both those value are address this should be stored in pointer how it is giving intiger value?
code-- https://ide.codingblocks.com/s/229357

hello @anubhavb11

Pointer arithmetic in C is defined as follows-

Pointer arithmetic doesn’t allow following operations-

  1. Addition of 2 pointers
  2. Multiplication of a pointer with a constant(Integer)
  3. Division of a pointer with a constant

Pointer arithmetic allows following operations-

  1. Addition of a constant(Integer) to a pointer
  2. Subtraction of a constant(Integer) from a pointer
  3. Subtraction of 2 pointers

Now let’s see what happens in the above 3 operations-

Addition of a constant N to a pointer returns another pointer which holds the address of the element present after N blocks from current memory location in the memory.

Similarly Subtraction of a constant N from a pointer returns another pointer which holds the address of the element present before N blocks in the memory.

Subtraction of 2 pointers returns the number of blocks present between the 2 addresses pointed by the 2 pointers.(which is an integer of course…).