Access array elements using pointer arithmetic Dry Run in C

Access array elements using pointer arithmetic is an interactive C dry run visualizer from the Pointersintro 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.

Access array elements using pointer arithmetic Program Code

#include <stdio.h>

int main() {
    int arr[] = {10, 20, 30, 40, 50};
    int *ptr = arr;
    
    printf("arr[0] = %d, *(ptr + 0) = %d\n", arr[0], *(ptr + 0));
    printf("arr[1] = %d, *(ptr + 1) = %d\n", arr[1], *(ptr + 1));
    printf("arr[2] = %d, *(ptr + 2) = %d\n", arr[2], *(ptr + 2));
    printf("arr[3] = %d, *(ptr + 3) = %d\n", arr[3], *(ptr + 3));
    printf("arr[4] = %d, *(ptr + 4) = %d\n", arr[4], *(ptr + 4));
    
    return 0;
}

View the complete Pointersintro programs page.

Program Console Access array elements using pointer arithmetic Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.