Code
/*
* -----------------------------------------------------------
* Logic Building with Computer Programming (CSU1128P)
* Instructor: Abdullahi Adem | Author: Divya Mohan
*
* This code is a part of the educational initiative by dmj.one
* with aim of empowering and inspiring learners in the field of
* Computer Science and Engineering through the respective courses.
*
* (c) 2022, Divya Mohan for dmj.one. All rights reserved.
* -----------------------------------------------------------
*/
#include <stdio.h>
int main()
{
int d, m, j, o, n = 0;
printf("\n\n -- This program compares two matrices and checks if they are identical or not --\n\n");
printf("Enter the number of rows and columns of matrix. \nExample: For a matrix with 2 row and 2 column; enter 2 2 and press {Enter}: ");
scanf("%d %d", &d, &m);
int a[d][m], b[d][m];
printf("\n\tStarting with row 1, enter the %d elements of first matrix: ", d * m);
for (o = 0; o < d; o++)
{
for (j = 0; j < m; j++)
{
scanf("%d", &a[o][j]);
}
}
printf("\n\tStarting with row 1, enter the %d elements of second matrix: ", d * m);
for (o = 0; o < d; o++)
{
for (j = 0; j < m; j++)
{
scanf("%d", &b[o][j]);
}
}
for (o = 0; o < d; o++)
{
for (j = 0; j < m; j++)
{
if (a[o][j] != b[o][j])
{
n = 1;
break;
}
}
}
if (n == 0)
{
printf("\n\t\tThe matrices are identical\n\n");
}
else
{
printf("\n\t\tThe matrices are not identical\n\n");
}
return 0;
}
Output
Program to check maximum between three numbers
-- This program compares two matrices and checks if they are identical or not --
Enter the number of rows and columns of matrix.
Example: For a matrix with 2 row and 2 column; enter 2 2 and press {Enter}: 2 1
Starting with row 1, enter the 2 elements of first matrix: 1 2
Starting with row 1, enter the 2 elements of second matrix: 2 1
The matrices are not identical