Replace Negative Numbers in 3D Array with Zero Dry Run in C

Replace Negative Numbers in 3D Array with Zero 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.

Replace Negative Numbers in 3D Array with Zero Program Code

#include <stdio.h>
int main() {
    int arr[2][3][4] = {5,-3,8,-1,0,4,-7,2,9,-5,6,-2,
                        3,-8,1,-4,7,-6,10,-9,11,-10,12,-11};
    int i, j, k;
    for(i =0;i<2;i++)
        for(j =0;j<3;j++)
            for(k =0;k<4;k++)
                if(arr[i][j][k] < 0)
                    arr[i][j][k] = 0;
    
    printf("Sample: arr[0][0][1] = %d\n", arr[0][0][1]);
    return 0;
}

View the complete Multi D programs page.

Program Console Replace Negative Numbers in 3D Array with Zero Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.