-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpperTriangle.java
More file actions
29 lines (29 loc) · 825 Bytes
/
UpperTriangle.java
File metadata and controls
29 lines (29 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.*;
public class UpperTriangle
{
public static void main(String[] args)
{
System.out.println("UPPER TRIANGULAR MATRIX");
Scanner sc=new Scanner(System.in);
System.out.print("Order of Square Matrix [int]->");
int n=sc.nextInt();
int[][] dda=new int[n][n];
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
System.out.print("Element ["+(i+1)+"x"+(j+1)+"] [int]->");
dda[i][j]=sc.nextInt();
}
}
boolean flag=true;
for(int i=0;i<n;i++)
{
for(int j=0;j<i;j++)
{
if(dda[i][j]!=0) flag=false;
}
}
System.out.println((flag)?"Upper Triangular Matrix":"Not Upper Triangular Matrix");
}
}