-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultiplication of array.c
57 lines (51 loc) · 1.1 KB
/
multiplication of array.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
#include<stdio.h>
//You can also use #define N 50 so that we can directly allot memory to array. we can write a[N][N]
int main()
{
int i,j,k,m,n,a[100][100],b[100][100],c[100][100];
printf("Enter the no of rows: ");
scanf("%d",&m);
printf("Enter the no of columns: ");
scanf("%d",&n);
printf("enter the values of 1st matrix: \n");
{
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
}
printf("enter the values of 2nd matrix: \n");
{
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&b[i][j]);
}
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
c[i][j]=0;
for(k=0;k<n;k++)
{
c[i][j]+=a[i][k]*b[k][j];
}
}
}
printf("The product of two matrices are: \n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("%d\t",c[i][j]);
}
printf("\n");
}
return 0;
}