package Mobile.Arrays;
import java.util.Scanner;
public class Matrix_Upper_Triangular
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a[][]=new int[10][10];
System.out.println("Enter elements for Matrix");
for(int i=1;i<=3;i++)
{
for(int j=1;j<=3;j++)
{
a[i][j]=sc.nextInt();
}
}
System.out.println("Matrix is");
for(int i=1;i<=3;i++)
{
for(int j=1;j<=3;j++)
{
System.out.print("\t"+a[i][j]);
}
System.out.print("\n");
}
System.out.println("Upper Triangular matrix is");
for(int i=1;i<=3;i++)
{
for(int j=1;j<=3;j++)
{
if(i<=j)
System.out.print("\t"+a[i][j]);
else
System.out.print("\t");
}
System.out.print("\n");
}
}
}
import java.util.Scanner;
public class Matrix_Upper_Triangular
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a[][]=new int[10][10];
System.out.println("Enter elements for Matrix");
for(int i=1;i<=3;i++)
{
for(int j=1;j<=3;j++)
{
a[i][j]=sc.nextInt();
}
}
System.out.println("Matrix is");
for(int i=1;i<=3;i++)
{
for(int j=1;j<=3;j++)
{
System.out.print("\t"+a[i][j]);
}
System.out.print("\n");
}
System.out.println("Upper Triangular matrix is");
for(int i=1;i<=3;i++)
{
for(int j=1;j<=3;j++)
{
if(i<=j)
System.out.print("\t"+a[i][j]);
else
System.out.print("\t");
}
System.out.print("\n");
}
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.