forked from wbhima/CodeforALL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
matrix-multiplication
48 lines (48 loc) · 991 Bytes
/
matrix-multiplication
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
#include <iostream>
using namespace std;
int main()
{
int A[10][10],B[10][10],mul[10][10],r,c,i,j,k;
cout<<"Enter the number of row=";
cin>>r;
cout<<"Enter the number of column=";
cin>>c;
cout<<"Enter the first matrix element=\n";
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
cin>>A[i][j];
}
}
cout<<"Enter the second matrix element=\n";
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
cin>>B[i][j];
}
}
cout<<"Multiply of the matrix=\n";
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
mul[i][j]=0;
for(k=0;k<c;k++)
{
mul[i][j]+=A[i][k]*B[k][j];
}
}
}
//for printing result
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
cout<<mul[i][j]<<" ";
}
cout<<"\n";
}
return 0;
}