How come although two of the cout are the same, *(ptr +2), however the first shows 2 but the second one shows 5?
The first time *(ptr1+2) is executed it is 2 yes.
On next line you increment *ptr1 by 3.
then you print *(ptr1+2) again.
And last time i checked 3 + 2 is equal to 5. :-)