Traverse array using pointer Dry Run in C

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

Traverse array using pointer Program Code

#include <stdio.h>
int main() {
    int arr[] = {10, 20, 30, 40, 50, 60, 70};
    int n = sizeof(arr)/sizeof(arr[0]);
    int *start = arr;
    int *end = arr + n - 1;
    
    printf("Forward traversal:\n");
    for(int *p = start; p <= end; p++) {
        printf("%d ", *p);
    }
    
    printf("\n\nBackward traversal:\n");
    for(int *p = end; p >= start; p--) {
        printf("%d ", *p);
    }
    
    return 0;
}

View the complete Pointersintro programs page.

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