Question: ```
short x = 5;        
short*ptr = &x;     
short *ptr2 = ptr+5; 

cout << ptr2 - ptr << endl;
cout << (long) ptr2 - (long)ptr << endl;

```

I understand that pointers store addresses, but I don't understand why the answer for both lines isn't 10.

Isn't ptr2 = address of pointer + sizeof(short) \* 5?

Answer: 
Pointer arithmetic is expressed in terms of elements of the type that is being pointed at.

`ptr+5` increments `ptr` by `5 * sizeof(short)` bytes.

The result of `ptr2 - ptr` is 5, because the compiler knows that `ptr` and `ptr2` are pointing at `short` elements, and so it divides the difference of the two memory addresses by `sizeof(short)`. The number of `short` elements between those 2 memory addresses is 5.

Whereas `(long) ptr2 - (long)ptr` is not pointer arithmetic, it is just plain ordinary integer arithmetic. It calculates the difference of the 2 memory addresses as-is, without regard to what they are pointing at. Since there are 5 `short` elements between the 2 memory addresses , and `sizeof(short)` is clearly 2 bytes in your case, the distance between the 2 memory addresses is 10 bytes.
Pointer arithmetic does behave algebraically.

if y = x + 5, then y - x = 5. This is true if x and y are integers, or x and y are pointers to the same type.

Note that you can not do z = y + x with pointers. z does NOT equal 2x + 5. It does not even compile. You cannot add two pointers, but you can take the difference between two pointers (and get the count of elements).