C Program to Check Whether Two Matrices Are Equal or Not - Source Code, Output & Execution Flow

C Program to Check Whether Two Matrices Are Equal or Not

This tutorial explains c program to check whether two matrices are equal or not with C source code, sample output, and step-by-step execution flow.

#include <stdio.h>
int main() {
    int a[2][2] = {{1, 2}, {3, 4}}, b[2][2] = {{1, 2}, {3, 4}};
    int i, j, equal = 1;
    for (i = 0; i < 2; i++)
        for (j = 0; j < 2; j++)
            if (a[i][j] != b[i][j]) equal = 0;
    if (equal) printf("Matrices are equal.
");
    else printf("Matrices are not equal.
");
    return 0;
}
Matrices are equal.

In this program, the input is read first when required, the core logic is applied step by step, and the final result is displayed using printf(). Follow the execution flow beside the code to understand how each statement contributes to the output.