-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHA 5.7.cpp
More file actions
53 lines (53 loc) · 892 Bytes
/
HA 5.7.cpp
File metadata and controls
53 lines (53 loc) · 892 Bytes
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
#include<stdio.h>
main()
{
int i,j,k,size,flag=1;
printf("Enter size of square matrix: \n");
scanf("%d",&size);
int a[size][size],temp[size][size],identityCheck[size][size],sum=0;
printf("Enter Elements in matrix\n");
for(i=0;i<size;i++)
{
for(j=0;j<size;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0;i<size;i++)
{
for(j=0;j<size;j++)
{
temp[i][j]=a[j][i];
}
}
for(i=0;i<size;i++)
{
for(j=0;j<size;j++)
{
for(k=0;k<size;k++)
{
sum+=(a[i][k]*temp[k][j]);
}
identityCheck[i][j]=sum;
sum=0;
}
}
for(i=0;i<size;i++)
{
for(j=0;j<size;j++)
{
if(i==j && identityCheck[i][j]!=1)
flag=0;
if(i!=j && identityCheck[i][j]!=0)
flag=0;
}
}
if(flag==1)
{
printf("Given Matrix is Orthogonal Matrix\n");
}
else
{
printf("Given Matrix is not an Orthogonal Matrix\n");
}
}