Skip to content

Commit 76a0d19

Browse files
Matrix Multiplication #84
1 parent 518b6e5 commit 76a0d19

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

MatrixMultiply.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include <iostream>
2+
using namespace std;
3+
int main()
4+
{
5+
int a[10][10],b[10][10],mul[10][10],r,c,i,j,k;
6+
cout<<"enter the number of row=";
7+
cin>>r;
8+
cout<<"enter the number of column=";
9+
cin>>c;
10+
cout<<"enter the first matrix element=\n";
11+
for(i=0;i<r;i++)
12+
{
13+
for(j=0;j<c;j++)
14+
{
15+
cin>>a[i][j];
16+
}
17+
}
18+
cout<<"enter the second matrix element=\n";
19+
for(i=0;i<r;i++)
20+
{
21+
for(j=0;j<c;j++)
22+
{
23+
cin>>b[i][j];
24+
}
25+
}
26+
cout<<"multiply of the matrix=\n";
27+
for(i=0;i<r;i++)
28+
{
29+
for(j=0;j<c;j++)
30+
{
31+
mul[i][j]=0;
32+
for(k=0;k<c;k++)
33+
{
34+
mul[i][j]+=a[i][k]*b[k][j];
35+
}
36+
}
37+
}
38+
//for printing result
39+
for(i=0;i<r;i++)
40+
{
41+
for(j=0;j<c;j++)
42+
{
43+
cout<<mul[i][j]<<" ";
44+
}
45+
cout<<"\n";
46+
}
47+
return 0;
48+
}

0 commit comments

Comments
 (0)