Difference between arr[i] and *(arr+i) Dry Run in C

Difference between arr[i] and *(arr+i) is an interactive C dry run visualizer from the Pointersarrays programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

Difference between arr[i] and *(arr+i) Program Code

#include <stdio.h>
int main() {
    int i;
    int arr[] = {10, 20, 30, 40, 50};
    
    printf("Demonstrating equivalence:\n");
    for(i = 0; i < 5; i++) {
        printf("arr[%d] = %d, *(arr+%d) = %d", i, arr[i], i, *(arr+i));
        if(arr[i] == *(arr+i)) {
            printf(" → EQUAL\n");
        }
    }
    
    printf("\nAddress equivalence:\n");
    printf("&arr[0] = %p, arr = %p\n", &arr[0], arr);
    printf("&arr[1] = %p, arr+1 = %p\n", &arr[1], arr+1);
    printf("&arr[2] = %p, arr+2 = %p\n", &arr[2], arr+2);
    
    printf("\nWhat arr[i] means to compiler:\n");
    printf("arr[i] is converted to *(arr + i)\n");
    printf("i[arr] is also valid: 2[arr] = %d\n", 2[arr]);
    
    return 0;
}

View the complete Pointersarrays programs page.

Program Console Difference between arr[i] and *(arr+i) Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.