Computer Science, asked by kushagra9728, 1 year ago

Write a c program to perform arthimatic operations on pointers

Answers

Answered by CBSEMP
12
hey guys
We can't perform every type of arithmetic operations with pointers. Pointer arithmetic is slightly different from arithmetic we normally use in our day to day life. The only valid arithmetic operations applicable on pointers are:

Addition of integer to a pointerSubtraction of integer to a pointerSubtracting one pointer from another of the same type

The pointer arithmetic is performed relative to the base type of the pointer. For example: if we have an integer pointer ip which contains address 1000, then on incrementing it by 1, we will get 1004 (i.e 1000 + 1 * 4) instead of 1001 because the size of the int data type is 4bytes. If we had been using a system where the size of int is 2 bytes then we would get 1002 ( i.e 1000 + 1 * 2 ).

Similarly, on decrementing it we will get 996(i.e 1000 - 1 * 4) instead of 999. So the expression ip + 4 will point to address 1016(i.e 1000 + 4 * 4 ).

u need example say me I edit my answer
Answered by sumanrudra22843
0

Explanation:

Pointer arithmetic in C programming

Pointer arithmetic in C programmingC language provides a set of operators to perform arithmetic and comparison of memory addresses. ...

Pointer arithmetic in C programmingC language provides a set of operators to perform arithmetic and comparison of memory addresses. ...Or in simple terms, incrementing a pointer will cause the pointer to point to a memory location skipping N bytes from current pointed memory location. ...

Pointer arithmetic in C programmingC language provides a set of operators to perform arithmetic and comparison of memory addresses. ...Or in simple terms, incrementing a pointer will cause the pointer to point to a memory location skipping N bytes from current pointed memory location. ...Pointer increment operation increments pointer by one.

Similar questions