Upper Triangular Matrix Program in C++

Upper Triangular Matrix Program in C++

Check Whether a Given Matrix is an Upper Triangular Matrix or Not

Upper Triangular Matrix Program in C++

#include<iostream.h>
#include<conio.h>
void main()
{
int A[10][10],n,i,j;
cout<<"Enter the size of the the Matrix\n";
cin>>n;
cout<<"Enter the elements of the Matrix\n";
for(i=0;i<n;i++)
for(j=0;j<n;j++)
cin>>A[i][j];
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i<j)
{
if(A[i][j]==0)
break;
}
else
{
if(A[i][j]!=0)
break;
}
}
if(j<n)
break;
}
if(i<n)
cout<<"Given Matrix is Not an Upper Triangular Matrix\n";
else
cout<<"Given Matrix is an UPPER TRIANGULAR MATRIX\n";
getch();
}

Comments