-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathmatrixMultiplication.cpp
48 lines (48 loc) · 1 KB
/
matrixMultiplication.cpp
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;
}