-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDC40.cpp
47 lines (43 loc) · 1.12 KB
/
DC40.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
#include <iostream>
using namespace std;
int main(){
int n1rows, n2column, m1rows, m2column, j, sum = 0;
int matrix1[100][100];
int matrix2[100][100];
int matrix3[100][100];
cout << "Enter Rows & column of matrix1" << endl;
scanf("%d %d", &n1rows, &n2column);
cout << "Enter Metrix1 :-" << endl;
for (int i = 0; i < n1rows; i++)
{
for (int j = 0; j < n1rows; j++)
{
cin >> matrix1[i][j];
}
}
cout << "Enter Rows & column of matrix2" << endl;
scanf("%d %d", &m1rows, &m2column);
cout << "Enter Metrix2 :-" << endl;
for (int i = 0; i < m1rows; i++)
{
for (int j = 0; j < m2column; j++)
{
cin >> matrix1[i][j];
}
}
cout << "Result Metrix :- " << endl;
for (int i = 0; i < n1rows; i++)
{
for (int j = 0; j < m2column; j++)
{
for (int k = 0; k < m2column ; k++)
{
sum += matrix1[i][k] * matrix2[k][j];
}
}
matrix3[i][j] = sum;
cout << matrix3[i][j] << endl;
printf("\n");
}
return 0;
}