-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrix Multiplication
More file actions
47 lines (42 loc) · 1.08 KB
/
Copy pathMatrix Multiplication
File metadata and controls
47 lines (42 loc) · 1.08 KB
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
#include <stdio.h>
int main()
{
printf("Enter The size of 1st matrix ");
int a,b,aa,bb;
scanf("%d%d",&a,&b);
printf("Enter The size of 2nd matrix ");
scanf("%d%d",&aa,&bb);
if(a==bb)
{
int arr1[a][b],arr2[aa][bb],arr3[a][bb];
printf("Enter The 1st matrix ");
for (int i=0;i<a;i++)
for (int j=0;j<b;j++)
scanf("%d",&arr1[i][j]);
printf("Enter The 2nd matrix ");
for (int i=0;i<aa;i++)
for (int j=0;j<bb;j++)
scanf("%d",&arr2[i][j]);
for (int i=0;i<a;i++)
{
for (int j=0;j<bb;j++)
{
int d=0;
for (int k=0;k<b;k++)
{
d=d+(arr1[i][k]*arr2[k][j]);
}
arr3[i][j]=d;
d=0;
}
}
printf(" The matrix After multiplication is\n");
for (int i=0;i<a;i++)
{
for (int j=0;j<bb;j++)
printf("%d ",arr3[i][j]);
printf("\n");
}
}
return 0;
}