/* Write a program to find whether the matrix is a rectangular or a square or a scalar matrix. */
#include<iostream.h>
#include<conio.h>
void main()
{
int a[5][5],r,c,i,j,scalar,scalarele;
clrscr();
cout<<"Enter the order: ";
cin>>r>>c;
cout<<"Enter the elements of the
matrix:\n";
for(i=0;i<r;i++)
for(j=0;j<c;j++)
cin>>a[i][j];
if(r==c)
{
cout<<"It is a square and
";
scalar=1;
scalarele=a[0][0];
for(i=0;i<r;i++)
for(j=0;j<c;j++)
if(i==j)
{
if(a[i][j]!=scalarele)
{
scalar=0;
break;
}
}
else if(a[i][j]!=0)
{
scalar=0;
break;
}
if(scalar)
cout<<"scalar";
else
cout<<"not scalar";
}
else
cout<<"It is a rectangular
matrix";
getch();
}

No comments: