## C pointer expression for a[i][j]

Consider we are having the array – say arr[6]. We know that we can access the first element of an array using the a[0].

int arr[] = {11,22,33,44,55,66}

Array Element | Element Accessed | Element |
---|---|---|

arr[0] | Accessing first element of an array | 11 |

arr[1] | Accessing second element of an array | 22 |

arr[2] | Accessing third element of an array | 33 |

arr[3] | Accessing fourth element of an array | 44 |

arr[4] | Accessing fifth element of an array | 55 |

arr[5] | Accessing sixth element of an array | 66 |

Whenever we are accessing the element of an array then we are adding index in the base address of an array and using the value of operator we are fetching the value.

Array Element | Equivalent pointer expression |
---|---|

arr[0] | *(arr+0) |

arr[1] | *(arr+1) |

arr[2] | *(arr+2) |

arr[3] | *(arr+3) |

arr[4] | *(arr+4) |

arr[5] | *(arr+5) |

Read more : Accessing Array Element indirectly using pointer.

## Equivalent Pointer Expression for a[i][j]

We can summarize the following chart using the above theory –

Array | Equivalent Pointer Exp. |
---|---|

a[i][j] | *(*(a + i)+j) |

a[i][j][k] | *(*(*(a + i ) +j ) +k) |

a[i][j][k][l] | *(*(*(*(a + i ) +j ) +k) +l) |

## C Program : Pointer Expression

#include <stdio.h> int main() { int arr[5] = {11,22,33,44,55}; int i; for(i=0;i<5;i++) { printf("%d ",*(arr + i)); } return 0; }

You can also visit our some of the tutorial to learn more about C programming pointer expression –

meaning of (*++ptr) pointer expression | meaning of (++*ptr) pointer expression