Symmetric Matrix In Java ISC

11---Program to declare a square matrix A[ ] [ ] of order (M x M) such that M must be greater than 2 and less than 10 and check whether it is a Symmetric matrix or not.

class Symmetric{
//start of class
public void accept(int as[][]){
int r=as.length;
int c=as[0].length;int d=0;
if(c!=r|| c<2||c>10){
System.out.println("Not a Symmetric matrix");
System.exit(1);
}
for(int i=0;i<r;i++){
for(int j=0;j<c;j++){
if(as[i][j]!=as[j][i])
d++;
}}
if(d==0)
System.out.println("The Given matix is Symmetric");
else
System.out.println("not a symmetric matrix");
}}//end of class

OUTPUT---
WHEN INPUT IS {{1,2,3},{5,6,7}} OUTPUT IS
Not a Symmetric matrix

Comments

Popular posts from this blog

Sort Boundary Elements Of A Matrix

Lucky Number In Java ISC

Program to fill a square matrix of size ‘n*n” in a circular fashion (clockwise) with natural numbers from 1 to n*n, taking ‘n’ as input.