-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmatrixmul.cpp
More file actions
45 lines (44 loc) · 728 Bytes
/
matrixmul.cpp
File metadata and controls
45 lines (44 loc) · 728 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
#include<iostream>
using namespace std;
int main()
{
int mat1[3][3], mat2[3][3], mat3[3][3], sum=0;
cout<<"Enter first matrix element (3*3) : ";
for(int i=0; i<3; i++)
{
for(int j=0; j<3; j++)
{
cin>>mat1[i][j];
}
}
cout<<"Enter second matrix element (3*3) : ";
for(int i=0; i<3; i++)
{
for(int j=0; j<3; j++)
{
cin>>mat2[i][j];
}
}
cout<<"Multiplying two matrices...\n";
for(int i=0; i<3; i++)
{
for(int j=0; j<3; j++)
{
sum=0;
for(int k=0; k<3; k++)
{
sum = sum + mat1[i][k] * mat2[k][j];
}
mat3[i][j] = sum;
}
}
cout<<"\nMultiplication of two Matrices : \n";
for(int i=0; i<3; i++)
{
for(int j=0; j<3; j++)
{
cout<<mat3[i][j]<<" ";
}
cout<<"\n";
}
}