3D Array Boundary Elements Sum Dry Run in C

3D Array Boundary Elements Sum is an interactive C dry run visualizer from the Multi D 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.

3D Array Boundary Elements Sum Program Code

#include <stdio.h>
int main() {
    int arr[3][4][5], i, j, k;
    int l=3, r=4, c=5;
    int sum = 0;
    
    // Initialize
    for(i =0;i<l;i++)
        for(j =0;j<r;j++)
            for(k =0;k<c;k++)
                arr[i][j][k] = i*100 + j*10 + k;
    
    // Sum boundary elements
    for(i =0;i<l;i++) {
        for(j =0;j<r;j++) {
            for(k =0;k<c;k++) {
                if(i==0 || i==l-1 || j==0 || j==r-1 || k==0 || k==c-1) {
                    sum += arr[i][j][k];
                }
            }
        }
    }
    
    printf("Sum of boundary elements = %d\n", sum);
    return 0;
}

View the complete Multi D programs page.

Program Console 3D Array Boundary Elements Sum Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.