For Details of The Program: CLICK HERE
import
java.io.*;
class Prog2
{
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in)); int a[][];
int i,j,m;
public void
show()throws Exception
{
System.out.println("Enter the number of
rows:"); m=Integer.parseInt(br.readLine()); if(m<=2 || m>=20)
{
System.out.println("\nSize out of
range:"); return;
}
a=new
int[m][m];
for(i=0;i< m;i++)
{
for(j=0;j< m;j++)
{
System.out.println("Enter value:");
System.out.println("Enter value:");
a[i][j]=Integer.parseInt(br.readLine());
}
}
System.out.println("\nOriginal
matrix\n");
for(i=0;i< m;i++)
{
for(j=0;j< m;j++)
{
System.out.print("
"+a[i][j]);
}
}
System.out.println("\nMirror
image matrix\n");
for(i=0;i< m;i++)
{
for(j=m-1;j >=0;j--)
{
System.out.print(" "+a[i][j]);
}
System.out.print(" "+a[i][j]);
}
System.out.println();
}
}
}
public static
void main(String args[]) throws Exception
{
Prog2 ob=new
Prog2();
ob.show();
}
}
2013 Computer Practical Paper: CLICK HERE
No comments:
Post a Comment