-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultiplication.c
61 lines (52 loc) · 938 Bytes
/
multiplication.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
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
puts("enter the row and column number for the two matrix");
int row1,column1,row2,column2;
scanf("%d%d%d%d",&row1,&column1,&row2,&column2);
int mat1[row1][column1],mat2[row2][column2];
puts("enter the first matrix");
for(int i=0;i<row1;i++)
{
for(int j=0;j<column1;j++)
{
scanf("%d",&mat1[i][j]);
}
}
puts("enter the second matrix");
for(int i=0;i<row2;i++)
{
for(int j=0;j<column2;j++)
{
scanf("%d",&mat2[i][j]);
}
}
int resMat[row1][column2];
for(int i=0;i<row1;i++)
{
for(int j=0;j<column2;j++)
{
resMat[i][j]=0;
}
}
for(int i=0;i<row1;i++)
{
for(int j=0;j<column2;j++)
{
for(int k=0;k<column1;k++)
{
resMat[i][j]+=(mat1[i][k]*mat2[k][j]);
}
}
}
for(int i=0;i<row1;i++)
{
for(int j=0;j<column2;j++)
{
printf("%d ",resMat[i][j]);
}
puts("");
}
}