# Mirror Image of Matrix ISC 2013 Practical

Write a program to declare a square matrix a[][] of order (m × m) where ‘m’ is the number of rows and the number of columns such that ‘m’ must be greater than 2 and less than 20. Allow the user to input integers into this matrix. Display appropriate error message for an invalid input. Perform the following tasks:
(a) Display the input matrix.
(b) Create a mirror image of the inputted matrix.
(c) Display the mirror image matrix.

Test your program for the following data and some random data:

Example 1:
INPUT: M = 3

`4    16   128    2    146    1    3`

OUTPUT:
ORIGINAL MATRIX

`4    16   128    2    146    1    3`

MIRROR IMAGE MATRIX

`12   16   414   2    83    1    6`

Example 2:
INPUT: M = 22
OUTPUT: SIZE OUT OF RANGE

``````import java.io.*;
class Mirror{
public static void main(String args[])throws IOException{
System.out.print("m = ");
if(m < 3 || m > 19){
System.out.println("SIZE OUT OF RANGE");
return;
}
int a[][] = new int[m][m];
int b[][] = new int[m][m];
int p = 0;
int q = m - 1;
System.out.println("Enter matrix elements:");
for(int i = 0; i < m; i++){
q = m - 1;
for(int j = 0; j < m; j++){
b[p][q] = a[i][j];
q--;
}
p++;
}
System.out.println("ORIGINAL MATRIX");
for(int i = 0; i < m; i++){
for(int j = 0; j < m; j++){
System.out.print(a[i][j] + "\t");
}
System.out.println();
}
System.out.println("MIRROR IMAGE MATRIX");
for(int i = 0; i < m; i++){
for(int j = 0; j < m; j++){
System.out.print(b[i][j] + "\t");
}
System.out.println();
}
}
}``````

## 4 thoughts on “Mirror Image of Matrix ISC 2013 Practical”

1. sayan rana on said:

Sir,how to find LCM of 2 numbers by recursive function in JAVA?Can you please show me the code?

• admin on said:
2. sayan rana on said:

Sir,a program is given which states that:
WAP in Java to accept 2 numbers. Then find the HCF as well as the LCM of the 2 nos using recursive function.

• admin on said:

Follow https://www.happycompiler.com/recursion-examples/ to access recursive function to find the GCD and then calculate LCM as product of the two numbers divided by GCD.

This site uses Akismet to reduce spam. Learn how your comment data is processed.