C++ Pointers and Arrays

Declare an array of integers:

int arr[5];

Declare a pointer to an integer and assign it to the first element of the array:

int *ptr = &arr[0];

Access and modify the third element of the array using pointer arithmetic:

*(ptr + 2) = 10;

Access and modify the fourth element of the array using array notation:

arr[3] = 20;