Arithmetic Operation With Pointer

In a C programming, we can also perform arithmetic operations with pointer.

There are four arithmetic operators that can be performed with pointers:

  • Increment (++)
  • Decrement ( — )
  • Addition ( + )
  • Subtraction ( – )

 For a simple variable
int a=3;
a++; //print 4
Increment integer value by one.

Pointer is a variable which can hold the address of another variable in above code

For pointer
int a=3;
int *ptr;
ptr++; //increment by one integer address space

pointer variable address value are incremented based on type of values it holds

Increment a Pointer

Example: Write a program in c language, to increments the variable pointer to access each succeeding element of the array.


In above program we can also decrements the pointer.

In above program you have to loop in decrement way as below

NULL Pointers in C Programming

A pointer that is assigned NULL is called a null pointer. We must initialize NULL pointer during variable declaration.

A null pointer refers to pointer variable that does not point to a valid address.

Generally NULL pointer is used when you do not have an exact address to be assigned.


Pointer to Pointer in C Programming

In  C language, a pointer is an address. Normally, a pointer variable contains the address of a another variable. 

A pointer to a pointer is a chain of pointers. 


Pointer to pointer means one pointer variable holds the address of another pointer variable.

Pointer to Pointer
Fig: Pointer to Pointer
Fig: Pointer to Pointer Example