-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy patharraymultiplication.c
73 lines (58 loc) · 1.45 KB
/
arraymultiplication.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
62
63
64
65
66
67
68
69
70
71
72
73
#include<stdio.h>
int main()
{
int i,j,row,column;
int A[5][5],B[5][5],Res[5][5];
// first matrix
printf("Enter the number of rows ( less than 5 ) : ");
scanf("%d",&row);
printf("Enter number of columns ( less than 5 ) : ");
scanf("%d",&column);
// inserting elements in A[5][5]
printf("Enter the elements : ");
for (i=0;i<row;i++)
{
for (j=0;j<column;j++)
{
scanf("%d",&A[5][5]);
}
}
// second matrix
printf("Enter the number of rows ( less than 5 ) : ");
scanf("%d",&row);
printf("Enter number of columns ( less than 5 ) : ");
scanf("%d",&column);
// inserting elements in B[5][5]
printf("Enter the elements : ");
for (i=0;i<row;i++)
{
for (j=0;j<column;j++)
{
scanf("%d",&B[5][5]);
}
}
// multiplication of matrix
int k=(0,1);
printf("multiplication of matix \n",Res[i][j]);
for(i=0;i<row;i++)
{
for(j=0;j<column;j++)
{
Res[i][j]=0;
for(k=0;k<column;k++)
{
Res[i][j]+=A[i][k]*B[k][j];
}
}
}
// printing result
for(i=0;i<row;i++)
{
for(j=0;j<column;j++)
{
printf("%d \t",Res[i][j]);
}
printf("\n");
}
return 0;
}