Skip to content

Commit a5f5c4b

Browse files
author
=
committed
strmatrix.c added
1 parent 4b3919d commit a5f5c4b

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

matrix/strmatrix.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include<stdio.h>
2+
int main()
3+
{
4+
int A[2][2],B[2][2],C[2][2],i,j,p1,p2,p3,p4,p5,p6,p7;
5+
printf("Enter the elements of matrix A\n");
6+
for(i=0;i<2;i++)
7+
{
8+
for(j=0;j<2;j++)
9+
{
10+
scanf("%d",&A[i][j]);
11+
}
12+
}
13+
printf("Enter the elements of matrix B\n");
14+
for(i=0;i<2;i++)
15+
{
16+
for(j=0;j<2;j++)
17+
{
18+
scanf("%d",&B[i][j]);
19+
}
20+
}
21+
p1=A[0][0]*(B[0][1]-B[1][1]);
22+
p2=(A[0][0]+A[0][1])*B[1][1];
23+
p3=(A[1][0]+A[1][1])*B[0][0];
24+
p4=A[1][1]*(B[1][0]-B[0][0]);
25+
p5=(A[0][0]+A[1][1])*(B[0][0]+B[1][1]);
26+
p6=(A[0][1]-A[1][1])*(B[1][0]+B[1][1]);
27+
p7=(A[0][0]-A[1][0])*(B[0][0]+B[0][1]);
28+
C[0][0]=p5+p4-p2+p6;
29+
C[0][1]=p1+p2;
30+
C[1][0]=p3+p4;
31+
C[1][1]=p1+p5-p3-p7;
32+
printf("Printing the array C\n");
33+
for(i=0;i<2;i++)
34+
{
35+
for(j=0;j<2;j++)
36+
{
37+
printf("%d\t",C[i][j]);
38+
}
39+
printf("\n");
40+
}
41+
return 0;
42+
}

0 commit comments

Comments
 (0)