-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrix_Multiplication.cpp
More file actions
57 lines (45 loc) · 904 Bytes
/
Matrix_Multiplication.cpp
File metadata and controls
57 lines (45 loc) · 904 Bytes
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
#include <iostream>
using namespace std;
int main()
{
int a[3][3],b[3][3],Result[3][3],i,j;
int mul = 0;
cout<<"Enter the 1st Matrix\n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cin>>a[i][j];
}
}
cout<<"Enter the 2nd Matrix\n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cin>>b[i][j];
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
for(int k=0;k<3;k++)
{
mul += a[i][k] * b[k][j];
}
Result[i][j] = mul;
mul = 0;
}
}
cout<<"The Multiplication of 1st and 2nd Matrix is:\n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<Result[i][j]<<" ";
}
cout<<"\n";
}
return 0;
}