-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultiply_of_2_array.c
58 lines (52 loc) · 1020 Bytes
/
multiply_of_2_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
58
#include<stdio.h>
int main(){
int i,j,k,row1,column1,row2,column2,sum;
printf("Enter the number of row1 and column1\n");
scanf("%d%d",&row1,&column1);
printf("Enter the number of row2 and column2\n");
scanf("%d%d",&row2,&column2);
int a[5][5],b[5][5],c[5][5];
printf("Enter the elements of matrix1\n");
if(column1==row2)
{
for(i=0;i<row1;i++)
{
for(j=0;j<column1;j++)
{ printf("Enter element %d of %d ",i+1,j+1);
scanf("%d",&a[i][j]);
}
}
printf("Enter the value of second matrix\n");
for(i=0;i<row2;i++)
{
for(j=0;j<column2;j++)
{ printf("Enter element %d of %d ",i+1,j+1);
scanf("%d",&b[i][j]);
}
}
for(i=0;i<row1;i++)
{
for(j=0;j<column2;j++)
{
for(k=0;k<row2;k++)
{
sum=sum+(a[i][j]*b[i][j]);
}
c[i][j]=sum;
sum=0;
}
}
for(i=0;i<row1;i++)
{
for(j=0;j<column2;j++)
{
printf("%d\t",c[i][j]);
}
printf("\n");
}
}
else{
printf("multiplication not possible with the given column and matrix\n");
}
return 0;
}