Page 324 - Computer science 868 Class 12
P. 324
1 0 0 0
0 1 0 0
0 0 1 1
The matrix is a sparse matrix
Program 8 Write a program to display lower triangular matrix.
1 import java.util.*;
2 class Lower_Matrix
3 {
4 public static void main(String args[])
5 {
6
7 Scanner sc = new Scanner(System.in);
8 int size,i,j;
9 System.out.println("Enter the order of your Matrix ");
10 System.out.println("Enter the size:");
11 size = sc.nextInt();
12
13 int ar[][] = new int[size][size];
14 System.out.println("Enter your elements:");
15 for(i = 0; i < size; i++)
16 {
17 for(j = 0; j < size; j++)
18 {
19
20 ar[i][j] = sc.nextInt();
21 }
22 }
23 System.out.println("You have entered:");
24 for(i=0; i<size; i++)
25 {
26 for(j=0;j<size;j++)
27 {
28 System.out.print(ar[i][j] + " ");
322322 Touchpad Computer Science-XII

