Compare Two 4D Arrays for Equality Dry Run in C

Compare Two 4D Arrays for Equality 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.

Compare Two 4D Arrays for Equality Program Code

#include <stdio.h>
#include <stdbool.h>
int main() {
    int A[2][2][2][2], B[2][2][2][2], i, j, k, l;
    bool equal = true;
    
    for(i =0;i<2;i++) for(j =0;j<2;j++)
        for(k =0;k<2;k++) for(l =0;l<2;l++) {
            A[i][j][k][l] = i+j+k+l;
            B[i][j][k][l] = i+j+k+l;
        }
    
    for(i =0;i<2 && equal;i++)
        for(j =0;j<2 && equal;j++)
            for(k =0;k<2 && equal;k++)
                for(l =0;l<2;l++)
                    if(A[i][j][k][l] != B[i][j][k][l]) {
                        equal = false;
                        break;
                    }
    
    printf("Arrays are %s\n", equal ? "IDENTICAL" : "DIFFERENT");
    return 0;
}

View the complete Multi D programs page.

Program Console Compare Two 4D Arrays for Equality Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.