Monday 10 February 2020

CPP program to divide one matrix by the other

Source Code:
#include<iostream>
using namespace std;
int main()
{
int a[2][2],b[2][2],c[2][2],i,j;
cout<<"Enter first matrix: ";
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
cin>>a[i][j];
}
}

cout<<"Enter second matrix: ";
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
cin>>b[i][j];
}
}

for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
c[i][j]=a[i][j]/b[i][j];
}
}

cout<<"The product of the two matrix is: ";
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
cout<<c[i][j]<<endl;
}
}
return 0;
}

Program Output:


No comments:

Post a Comment