-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiplection of two metrix.cpp
More file actions
109 lines (81 loc) · 1.58 KB
/
Copy pathmultiplection of two metrix.cpp
File metadata and controls
109 lines (81 loc) · 1.58 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include<iostream>
using namespace std;
int main()
{
int a[10][10], b[10][10],c[10][10];
int x,y,i,j,m,n;
cout<<"\nEnter the number of rows and columns for Matrix A:::\n\n";
cin>>x>>y;
// x denotes number rows in matrix A
// y denotes number columns in matrix A
cout<<"\n\nEnter elements for Matrix A :::\n\n";
for(i=0;i<x;i++)
{
for(j=0;j<y;j++)
{
cin>>a[i][j];
}
cout<<"\n";
}
cout<<"\n\nMatrix A :\n\n";
for(i=0;i<x;i++)
{
for(j=0;j<y;j++)
{
cout<<"\t"<<a[i][j];
}
cout<<"\n\n";
}
cout<<"\n-----------------------------------------------------------\n";
cout<<"\nEnter the number of rows and columns for Matrix B:::\n\n";
cin>>m>>n;
// m denotes number rows in matrix B
// n denotes number columns in matrix B
cout<<"\n\nEnter elements for Matrix B :::\n\n";
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cin>>b[i][j];
}
cout<<"\n";
}
cout<<"\n\nMatrix B :\n\n";
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<"\t"<<b[i][j];
}
cout<<"\n\n";
}
if(y==m)
{
for(i=0;i<x;i++)
{
for(j=0;j<n;j++)
{
c[i][j]=0;
for(int k=0;k<m;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
cout<<"\n-----------------------------------------------------------\n";
cout<<"\n\nMultiplication of Matrix A and Matrix B :\n\n";
for(i=0;i<x;i++)
{
for(j=0;j<n;j++)
{
cout<<"\t"<<c[i][j];
}
cout<<"\n\n";
}
}
else
{
cout<<"\n\nMultiplication is not possible";
}
return 0;
}