#include<iostream>
using namespace std;
int main()
{
int i, j, rows, columns, flag = 1;
cout << "
Please Enter Matrix rows and Columns to find Identity Matrix = ";
cin >> i >> j;
int identMatrix[i][j];
cout << "
Please Enter the Identity Matrix Items
";
for(rows = 0; rows < i; rows++) {
for(columns = 0; columns < i; columns++) {
cin >> identMatrix[rows][columns];
}
}
for(rows = 0; rows < i; rows++)
{
for(columns = 0; columns < j; columns++)
{
if(identMatrix[rows][columns] != 1 && identMatrix[columns][rows] != 0)
{
flag = 0;
break;
}
}
}
if(flag == 1)
{
cout << "
The Matrix that you entered is an Identity Matrix";
}
else
{
cout << "
The Matrix that you entered is Not an Identity Matrix";
}
return 0;
}