-
Notifications
You must be signed in to change notification settings - Fork 0
/
bina.c
40 lines (39 loc) · 865 Bytes
/
bina.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
#include<stdio.h>
int main() {
int a[10][10],b[10][10],res[10][10],i,j,k,m,n,p,q;
printf("Enter the order of matrix A:");
scanf("%d%d",&m,&n);
printf("Enter the of order of matrix B:");
scanf("%d%d",&p,&q);
if(n==p) {
printf("Enter the elements of matrix A:");
for(i=0;i<m;i++) {
for(j=0;j<n;j++) {
scanf("%d",&a[i][j]);
}
}
printf("Enter the elements of matrix B:");
for(i=0;i<p;i++) {
for(j=0;j<q;j++) {
scanf("%d",&b[i][j]);
}
}
for(i=0;i<m;i++) {
for(j=0;j<q;j++) {
res[i][j]=0;
for(k=0;k<n;k++) {
res[i][j]+=a[i][k]*b[k][j];
}
}
}
for(i=0;i<m;i++) {
for(j=0;j<q;j++) {
printf("%d\t",res[i][j]);
}
printf("\n");
}
}
else{
printf("Matrix multiplication is not possible.");
}
}