C pointer arithmetic operations

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

Consider below table, We have declared some of the variables and also assumed some address for declared variables.

Data Type Initial Address Operation Address after Operations Required Bytes
int 4000 ++ 4002 2
int 4000 - - 3998 2
char 4000 ++ 4001 1
char 4000 - - 3999 1
float 4000 ++ 4004 4
float 4000 - - 3996 4
long 4000 ++ 4004 4
long 4000 - - 3996 4

We can see address of an variable after performing arithmetic operations.

Expression Result
Address + Number Address
Address – Number Address
Address – Address Number
Address + Address Illegal

Above table clearly shows that we can add or subtract address and integer number to get valid address. We can even subtract two addresses but we cannot add two addresses. Here are some pointer tutorials on Arithmetic Operations –

No Tutorial Link
1 Pointer Arithmetic : Incrementing Pointer Click Here
2 Pointer Arithmetic : Decrementing Pointer Click Here
3 Pointer Arithmetic : Addition of Pointer and Number Click Here
4 Pointer Arithmetic : Subtraction of Pointer and Number Click Here
5 Pointer Arithmetic : Differencing between two pointers Click Here
6 Pointer Arithmetic : Comparing two Popinters Click Here