# C++ Program to Check Whether the Matrix is Diagonal or Not Full Project For Beginners

Welcome folks today in this blog post we will be `checking whether the matrix is diagonal or not in c++`

All the full source code of the application is shown below.

In order to get started you need to make a `app.cpp`

file and copy paste the following code

`app.cpp`

```
#include<iostream>
using namespace std;
int main()
{
int m,i,j,z=0;
cout<<"Enter size of square matrix: ";
cin>>m;
int arr[m][m];
cout<<"Enter elements of your matrix: ";
for(i=0;i<=(m-1);i++)
for(j=0;j<=(m-1);j++)
cin>>arr[i][j];
for(i=0;i<=(m-1);i++)
{
for(j=0;j<=(m-1);j++)
if(i!=j && arr[i][j]==0)
{
z++;
}
}
if(z==m*m-m)
cout<<"nIt is a Diagonal Matrix";
else
cout<<"nIt is Not a Diagonal Matrix";
return 0;
}
```

### Similar Posts:

- None Found