Q:

# Write a program in C# Sharp to print or display the lower triangular of a given matrix

Write a program in C# Sharp to print or display the lower triangular of a given matrix.
Test Data :
Input the size of the square matrix : 3
Input elements in the first matrix :
element - [0],[0] : 1
element - [0],[1] : 2
element - [0],[2] : 3
element - [1],[0] : 4
element - [1],[1] : 5
element - [1],[2] : 6
element - [2],[0] : 7
element - [2],[1] : 8
element - [2],[2] : 9
Expected Output :
The matrix is :
1 2 3
4 5 6
7 8 9
Setting zero in lower triangular matrix
1 2 3
0 5 6
0 0 9

``````using System;
public class Exercise26
{
public static void Main()
{
int i,j,n;
int[,] arr1 = new int[10,10];
Console.Write("\n\nDisplay the lower triangular of a given matrix :\n");
Console.Write("----------------------------------------------------\n");
Console.Write("Input the size of the square matrix : ");
Console.Write("Input elements in the first matrix :\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
Console.Write("element - [{0}],[{1}] : ",i,j);
}
}
Console.Write("The matrix is :\n");
for(i=0;i<n;i++)
{
for(j=0;j<n ;j++)
Console.Write("{0}  ",arr1[i,j]);
Console.Write("\n");
}
Console.Write("\nSetting zero in lower triangular matrix\n");
for(i=0;i<n;i++){
Console.Write("\n");
for(j=0;j<n;j++)
if(i<=j)
Console.Write("{0}  ",arr1[i,j]);
else
Console.Write("{0}  ",0);
}
Console.Write("\n\n");
}
}``````