#include <stdio.h>

int main() {
    // An array of four elements.
    // Remember that "a" is a "constant pointer".
    int a[] = {10, 20, 30, 40};

    // A loop variable.
    int i;

    // Print the array elements and their address
    // using array subscript syntax (i.e. a[i])
    printf("With array subscript syntax:\n");

    for (i = 0; i < 4; i++) {
        printf("a[%d] value = %d address = %zu\n", i, a[i], &a[i]);
    }

    // Do the same thing, but with pointer arithmetic.
    printf("\nWith pointer arithmetic:\n");

    for (i = 0; i < 4; i++) {
        printf("a[%d] value = %d address = %zu\n", i, *(a + i), a + i);
    }

    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: