Print array using pointer notation Dry Run in C

Print array using pointer notation 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.

Print array using pointer notation Program Code

#include <stdio.h>
int main() {
    int i;
    int arr[] = {10, 20, 30, 40, 50, 60, 70};
    int n = sizeof(arr)/sizeof(arr[0]);
    int *ptr = arr;
    
    // Method 1: Using pointer arithmetic without moving ptr
    printf("Method 1 - *(ptr + i): ");
    for(i = 0; i < n; i++) {
        printf("%d ", *(ptr + i));
    }
    
    // Method 2: Moving pointer with increment
    printf("\nMethod 2 - ptr++: ");
    ptr = arr;
    for(i = 0; i < n; i++) {
        printf("%d ", *ptr);
        ptr++;
    }
    
    // Method 3: Using array name as pointer
    printf("\nMethod 3 - *(arr + i): ");
    for(i = 0; i < n; i++) {
        printf("%d ", *(arr + i));
    }
    
    return 0;
}

View the complete Pointersarrays programs page.

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