-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAmcat-automata-question11.c
71 lines (59 loc) · 1.43 KB
/
Amcat-automata-question11.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
/**
* C program to check whether two matrices are equal or not
*/
#include <stdio.h>
#define SIZE 3 // Matrix size
int main()
{
int A[SIZE][SIZE];
int B[SIZE][SIZE];
int row, col, isEqual;
/* Input elements in first matrix from user */
printf("Enter elements in matrix A of size %dx%d: \n", SIZE, SIZE);
for(row=0; row<SIZE; row++)
{
for(col=0; col<SIZE; col++)
{
scanf("%d", &A[row][col]);
}
}
/* Input elements in second matrix from user */
printf("\nEnter elements in matrix B of size %dx%d: \n");
for(row=0; row<SIZE; row++)
{
for(col=0; col<SIZE; col++)
{
scanf("%d", &B[row][col]);
}
}
/* Assumes that the matrices are equal */
isEqual = 1;
for(row=0; row<SIZE; row++)
{
for(col=0; col<SIZE; col++)
{
/*
* If the corresponding entries of matrices are not equal
*/
if(A[row][col] != B[row][col])
{
isEqual = 0;
break;
}
}
}
/*
* Checks the value of isEqual
* As per our assumption if isEqual contains 1 means both are equal
* If it contains 0 means both are not equal
*/
if(isEqual == 1)
{
printf("\nMatrix A is equal to Matrix B");
}
else
{
printf("\nMatrix A is not equal to Matrix B");
}
return 0;
}