Reverse array using pointer Dry Run in C

Reverse 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.

Reverse array using pointer Program Code

#include <stdio.h>
void reverseArray(int *start, int *end) {
    int temp;
    while(start < end) {
        temp = *start;
        *start = *end;
        *end = temp;
        start++;
        end--;
    }
}

int main() {
    int arr[] = {12, 45, 7, 89, 23, 56, 34};
    int n = sizeof(arr)/sizeof(arr[0]);
    int i;
    
    printf("Original array: ");
    for(i = 0; i < n; i++) {
        printf("%d ", arr[i]);
    }
    
    reverseArray(arr, arr + n - 1);
    
    printf("\nReversed array: ");
    for(i = 0; i < n; i++) {
        printf("%d ", arr[i]);
    }
    
    return 0;
}

View the complete Pointersintro programs page.

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