Take 3D Array Input from User Dry Run in C

Take 3D Array Input from User 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.

Take 3D Array Input from User Program Code

#include <stdio.h>
int main() {
    int layers, rows, cols, i, j, k;
    
    printf("Enter number of layers: ");
    scanf("%d", &layers);
    printf("Enter number of rows: ");
    scanf("%d", &rows);
    printf("Enter number of columns: ");
    scanf("%d", &cols);
    
    int arr[layers][rows][cols];
    
    printf("\nEnter elements:\n");
    for(i = 0; i < layers; i++) {
        for(j = 0; j < rows; j++) {
            for(k = 0; k < cols; k++) {
                printf("arr[%d][%d][%d] = ", i, j, k);
                scanf("%d", &arr[i][j][k]);
            }
        }
    }
    
    printf("\nYou entered:\n");
    for(i = 0; i < layers; i++) {
        printf("Layer %d:\n", i);
        for(j = 0; j < rows; j++) {
            for(k = 0; k < cols; k++) {
                printf("%4d ", arr[i][j][k]);
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

View the complete Multi D programs page.

Program Console Take 3D Array Input from User Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.