PROGRAM
//Program to check the equality of two matrices
# include <iostream>
using namespace std;
int main()
{
int flag=0,a[3][3],b[3][3],i,j;
cout<<"ENTER FIRST MATRIX ROW WISE:\n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<"a["<<i<<"]["<<j<<"]=";
cin>>a[i][j];
}
cout<<endl;
}
cout<<"ENTER SECOND MATRIX ROW WISE:\n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<"b["<<i<<"]["<<j<<"]=";
cin>>b[i][j];
}
cout<<endl;
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(a[i][j]!= b[i][j]) //checking for equality
{
flag==1;
break;
}
}
}
if(flag)
cout<<"MATRICES ARE UNEQUAL";
else
cout<<"MATRICES ARE EQUAL";
return 0;
}
OUTPUT
//Program to check the equality of two matrices
# include <iostream>
using namespace std;
int main()
{
int flag=0,a[3][3],b[3][3],i,j;
cout<<"ENTER FIRST MATRIX ROW WISE:\n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<"a["<<i<<"]["<<j<<"]=";
cin>>a[i][j];
}
cout<<endl;
}
cout<<"ENTER SECOND MATRIX ROW WISE:\n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<"b["<<i<<"]["<<j<<"]=";
cin>>b[i][j];
}
cout<<endl;
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(a[i][j]!= b[i][j]) //checking for equality
{
flag==1;
break;
}
}
}
if(flag)
cout<<"MATRICES ARE UNEQUAL";
else
cout<<"MATRICES ARE EQUAL";
return 0;
}
OUTPUT