Program to print Lower triangular matrix of an array

preview_player
Показать описание
Code is provided in the comment section :-)

Check my previous video on Lower & upper triangular matrix:

Рекомендации по теме
Комментарии
Автор

Code:


import java.util.Scanner;
class Low
{
public static void main(String args[])
{
Scanner obj=new Scanner(System.in);
System.out.println("Enter the no. of rows:");
int lr=obj.nextInt();
System.out.println("Enter the no. of columns:");
int lc=obj.nextInt();
int a[][]=new int[lr][lc];
for(int i=0;i<lr;i++)
{
for(int j=0;j<lc;j++)
{
System.out.println("Enter the number at "+i+j);
a[i][j]=obj.nextInt();
}
}
int lower[][]=new int[lr][lc];
for(int i=0;i<lr;i++)
{
for(int j=0;j<lc;j++)
{
if(i<j)
{
lower[i][j]=0;
}
else
{
lower[i][j]=a[i][j];
}
}
}
for(int i=0;i<lr;i++)
{
for(int j=0;j<lc;j++)
{

}
System.out.println();
}
}
}

KnowledgeAmplifier