Skip to content

Commit 152b3c6

Browse files
authored
Create 10.c
1 parent 031ad53 commit 152b3c6

File tree

1 file changed

+65
-0
lines changed
  • Special Programs

1 file changed

+65
-0
lines changed

Special Programs/10.c

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#include<stdio.h>
2+
void MultiMatrix(int (*a)[100],int (*b)[100],int (*c)[100],int r1,int c2,int r2)
3+
{
4+
int i,j,k;
5+
for(i=0;i<r1;i++)
6+
{
7+
for(j=0;j<c2;j++)
8+
{
9+
*(*(c+i)+j)=0;
10+
for(k=0;k<r2;k++)
11+
{
12+
*(*(c+i)+j)=*(*(c+i)+j)+(*(*(a+i)+k) * (*(*(b+k)+j)));
13+
}
14+
}
15+
}
16+
17+
}
18+
19+
int main()
20+
{
21+
int A[100][100],B[100][100],C[100][100];
22+
int i,j,r1,r2,c1,c2;
23+
printf("Enter the row of 1st matrix ");
24+
scanf("%d",&r1);
25+
printf("Enter the column of 1st matrix ");
26+
scanf("%d",&c1);
27+
for(i=0;i<r1;i++)
28+
{
29+
for(j=0;j<c1;j++)
30+
{
31+
printf("Enter the number ");
32+
scanf("%d",&A[i][j]);
33+
}
34+
}
35+
printf("Enter the row of 2nd matrix ");
36+
scanf("%d",&r2);
37+
printf("Enter the column of 2nd matrix ");
38+
scanf("%d",&c2);
39+
for(i=0;i<r2;i++)
40+
{
41+
for(j=0;j<c2;j++)
42+
{
43+
printf("Enter the number ");
44+
scanf("%d",&B[i][j]);
45+
}
46+
}
47+
if(c1==r2)
48+
{
49+
MultiMatrix(A,B,C,r1,c2,r2);
50+
printf("After multiplication :\n");
51+
for(i=0;i<r1;i++)
52+
{
53+
for(j=0;j<c2;j++)
54+
{
55+
printf("%d ",C[i][j]);
56+
}
57+
printf("\n");
58+
}
59+
}
60+
else
61+
{
62+
printf("Matrix multiplication not possible.");
63+
}
64+
return 0;
65+
}

0 commit comments

Comments
 (0)