forked from Siddhesh-3/hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatrixMultiplication.cpp
More file actions
41 lines (38 loc) · 868 Bytes
/
matrixMultiplication.cpp
File metadata and controls
41 lines (38 loc) · 868 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
#include <iostream>
using namespace std;
int main() {
int n,i,j,k;
cout<<"Enter the size of square matrices\n";
cin>>n;
int a[n][n], b[n][n], c[n][n];
cout<<"Enter all the elements of first matrix\n";
for ( i = 0; i < n; i++)
{
for ( j = 0; j < n; j++)
{
cin>>a[i][j];
}
}
cout<<"Enter all the elements of second matrix\n";
for ( i = 0; i < n; i++)
{
for ( j = 0; j < n; j++)
{
cin>>b[i][j];
}
}
for ( i = 0; i < n; i++)
{
for ( j = 0; j < n; j++)
{
c[i][j]=0;
for ( k = 0; k < n; k++)
{
c[i][j]+=a[i][k] * b[k][j];
}
cout<<c[i][j]<<" ";
}
cout<<endl;
}
return 0;
}