Reverse an array using function Dry Run in C

Reverse an array using function is an interactive C dry run visualizer from the Functions 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 an array using function Program Code

#include <stdio.h>

void reverseArray(int arr[], int size) {
    int temp;
    for(int i = 0; i < size/2; i++) {
        temp = arr[i];
        arr[i] = arr[size-1-i];
        arr[size-1-i] = temp;
    }
}

void printArray(int arr[], int size) {
    for(int i = 0; i < size; i++) {
        printf("%d ", arr[i]);
    }
    printf("\n");
}

int main() {
    int nums[] = {10, 20, 30, 40, 50, 60};
    int n = sizeof(nums) / sizeof(nums[0]);
    
    printf("Original: ");
    printArray(nums, n);
    
    reverseArray(nums, n);
    
    printf("Reversed: ");
    printArray(nums, n);
    return 0;
}

View the complete Functions programs page.

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