C pointer arithmetic operations



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

Data TypeInitial AddressOperationAddress after OperationsRequired Bytes
int4000++40022
int4000- -39982
char4000++40011
char4000- -39991
float4000++40044
float4000- -39964
long4000++40044
long4000- -39964

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

ExpressionResult
Address + NumberAddress
Address – NumberAddress
Address – AddressNumber
Address + AddressIllegal

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 –

NoTutorialLink
1Pointer Arithmetic : Incrementing PointerClick Here
2Pointer Arithmetic : Decrementing PointerClick Here
3Pointer Arithmetic : Addition of Pointer and NumberClick Here
4Pointer Arithmetic : Subtraction of Pointer and NumberClick Here
5Pointer Arithmetic : Differencing between two pointersClick Here
6Pointer Arithmetic : Comparing two PopintersClick Here