Suppose you are given a square matrix of size n x n, write a program to determine if this is an identity matrix. 2D array
Using Visual Studio 2015
===============================================================
#include<iostream>using namespace std;
#include<conio.h>
void main()
{
int array1[2][2];
for (int i = 0; i <= 1; i++)
{
for (int j = 0; j <= 1; j++)
{
cout<<"Enter the integers=";
cin>>array1[i][j];
}
}
for (int i = 0; i <= 1; i++)
{
for(int j = 0; j <= 1; j++)
{
cout<<array1[i][j];
}
cout<<endl;
}
if (array1[0][0] == 1 && array1[1][1] == 1 && array1[0][1] == 0 && array1[1][0] == 0)
{
cout << "\nIt is an identity matrix";
}
else
{
cout << "\nNot an identity matrix";
}
_getche();
}
=========================================================================
Comments
Post a Comment