Question

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

```				```
Example 1:
INPUT: M = 3
4    16   12
8    2    14
6    1    3
OUTPUT:
ORIGINAL MATRIX
4    16   12
8    2    14
6    1    3
MIRROR IMAGE MATRIX
12   16   4
14   2    8
3    1    6
Example 2:
INPUT: M = 22
OUTPUT: SIZE OUT OF RANGE

```
```

# Share code with your friends

Code

```				```
import java.util.Scanner;
public class MirrorMatrix
{
public static void main(String args[])
{
int i=0,j=0,m=0,row=0,col=0;
int arr[][],mirror[][];
Scanner sc=new Scanner(System.in);
System.out.print("M = ");
m = sc.nextInt();
if(m < 2 || m > 20)
{
System.out.println("SIZE OUT OF RANGE");

}
else
{
arr = new int[m][m];
System.out.println("Enter matrix elements:");
for(i = 0; i < m; i++)
{
for(j = 0; j < m; j++)
{
arr[i][j] = sc.nextInt();
}
}
System.out.println("ORIGINAL MATRIX");

for(i = 0; i < m; i++)
{
for(j = 0; j < m; j++)
{
System.out.print(arr[i][j] + "\t");
}
System.out.println();
}
mirror= new int[m][m];
row = 0;
col = m - 1;

for(i = 0; i < m; i++)
{
row = 0;
for(j = 0; j < m; j++)
{
mirror[row][col] = arr[i][j];
col--;
}
row++;
}

System.out.println("MIRROR MATRIX");
for(i = 0; i < m; i++)
{
for(j = 0; j < m; j++)
{
System.out.print(mirror[i][j] + "\t");
}
System.out.println();
}
}
}
}

```
```

Sale

50
Sale

150
Sale

200
Sale

50
Sale

50
Sale

50
Sale

50
Sale

50
Sale

50