forked from SoumyadeepMukherjee/Matrix_Manipulation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
identity.c
51 lines (44 loc) · 773 Bytes
/
identity.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
#include <stdio.h>
int main (void)
{
int a[10][10];
int i = 0, j = 0, row = 0, col = 0;
printf ("Enter the order of the matrix (mxn):\n");
printf ("where m = number of rows; and\n");
printf (" n = number of columns\n");
scanf ("%d %d", &row, &col);
int flag = 0;
printf ("Enter the elements of the matrix\n");
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
scanf ("%d", &a[i][j]);
}
}
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
if (i == j && a[i][j] != 1)
{
flag = -1;
break;
}
else if (i != j && a[i][j] != 0)
{
flag = -1;
break;
}
}
}
if (flag == 0)
{
printf ("It is a IDENTITY MATRIX\n");
}
else
{
printf ("It is NOT an identity matrix\n");
}
return 0;
}