InterviewSolution
Saved Bookmarks
| 1. |
WAP in JAVA to create a square matrix of 3 * 3 and store numbers in it. Check whether the matrix is symmetric on not. A square matrix is said to be symmetric, if the element of the ith row and the column is equal to the element of jth row and ith coloum. e.g.1 2 32 4 53 5 6 |
|
Answer» public class dsymmetric { public static void main (String args [ ]) { int i, j, k; k = 0; int m [ ] [ ] = new int [3] [3] ; System.out.print In (“The no. of matrix one”); for (i = 0; i < 3; i ++) { for (j = 0; j < 3; j ++) { System.out.print (m [i] [j] + “ ”); } System.out.printIn (); } for (i = 0; i < 3; i ++) { for (j = 0; j x 3; j ++) { eg (m[i][j] ! = m [j][i] k = 1; } } if (k = 0) System.out.print In (“It is symmetric”); else System.out.print In (“It is not symmetric”); } } |
|