-
Notifications
You must be signed in to change notification settings - Fork 0
/
Equality_of_matrix.c
79 lines (61 loc) · 1.24 KB
/
Equality_of_matrix.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//Equality of Matrix.
#include <stdio.h>
int main()
{
int matrix[3][3],matrixb[3][3],i,j,flag=0;
//input data to matrix.
printf("Matrix A:\n");
for (i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("INPUT: ");
scanf("%d",&matrix[i][j]);
}
}
//show stored data.
printf("\nThe Saved matrix is: ");
for(i=0;i<3;i++)
{
printf("\n");
for(j=0;j<3;j++)
{
printf("%d\t",matrix[i][j]);
}
}
//input for 2nd matrix.
printf("\nMatrix B:\n");
for (i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("INPUT: ");
scanf("%d",&matrixb[i][j]);
}
}
//show stored data.
printf("\nThe Saved matrix is: ");
for(i=0;i<3;i++)
{
printf("\n");
for(j=0;j<3;j++)
{
printf("%d\t",matrixb[i][j]);
}
}
//Equality checking:
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{
if(matrixb[i][j]==matrix[i][j])
{
flag++;
}
}
//Result display.
if(flag==9)
printf("\nMatrix are Identical.");
else
printf("\nMatrix are not Identical.");
return 0;
}