C++ Program To Multiply Two Square Matrices
C++ Program To Multiply Two Square Matrices
#include <iostream>
using namespace std;
int main()
{
int x[10][10],y[10][10],mul[10][10],row,col,i,j,k;
cout<<"Enter the Number of Rows = ";
cin>>row;
cout<<"Enter the Number of Column = ";
cin>>col;
cout<<"Enter the First Matrix Element = \n";
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
cin>>x[i][j];
}
}
cout<<"Enter the Second Matrix Element = \n";
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
cin>>y[i][j];
}
}
cout<<"Multiply of the Matrix=\n";
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
mul[i][j]=0;
for(k=0;k<col;k++)
{
mul[i][j]+=x[i][k]*y[k][j];
}
}
}
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
cout<<mul[i][j]<<" ";
}
cout<<"\n";
}
}