google.com, pub-6167773875660516, DIRECT, f08c47fec0942fa0 Write a program to find whether the matrix is a rectangular or a square or a scalar matrix - 2nd puc computer science

Write a program to find whether the matrix is a rectangular or a square or a scalar matrix

 /* 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();

}

Write a program to find whether the matrix is a rectangular or a square or a scalar matrix Write a program to find whether the matrix is a rectangular or a square or a scalar matrix Reviewed by Vision Academy on February 27, 2022 Rating: 5

No comments:

CheckOut

Powered by Blogger.