Access array elements using pointer Dry Run in C

Access array elements using pointer 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.

Access array elements using pointer Program Code

#include <stdio.h>
int main() {
    int arr[] = {10, 20, 30, 40, 50};
    int *ptr = arr;  // ptr points to first element
    
    printf("Accessing array elements using pointer:\n");
    printf("arr[0] = %d, *ptr = %d\n", arr[0], *ptr);
    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 Pointersarrays programs page.

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