-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrix.java
More file actions
27 lines (25 loc) · 798 Bytes
/
Copy pathMatrix.java
File metadata and controls
27 lines (25 loc) · 798 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
//Program to 4x4 matrix without its diagonals
import java.util.Scanner;
class Matrix {
public static void main(String[] args) {
Scanner ob = new Scanner(System.in);
int a[][] = new int[4][4];
System.out.println("Enter a matrix of order 4x4");
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
a[i][j] = ob.nextInt();
}
}
System.out.println("Modified Matrix");
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
if ((i == j) || (i + j == 3)) {
System.out.print(" ");
} else {
System.out.print(a[i][j] + " ");
}
}
System.out.println("");
}
}
}