forked from Anubhav-1020/Hacktoberfest-Beginners
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrixDeterminant.java
More file actions
32 lines (22 loc) · 820 Bytes
/
MatrixDeterminant.java
File metadata and controls
32 lines (22 loc) · 820 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
30
31
32
/*
------------------------------------------------------------------------------------------------
DESCRIPTION: THIS IS A PROGRAM TO CALCULATE THE DETERMINANT OF A MATRIX
------------------------------------------------------------------------------------------------
*/
import java.util.Scanner;
public class DeterminantMatrix {
private static Scanner inp;
public static void main(String[] args) {
int[][] arr = new int[2][2];
int i, j, determinant = 0;
inp= new Scanner(System.in);
System.out.println("\n Please Enter the Matrix Items : ");
for(i = 0; i < 2; i++) {
for(j = 0; j < 2; j++) {
arr[i][j] = sc.nextInt();
}
}
determinant = (arr[0][0] * arr[1][1]) - (arr[0][1] * arr[1][0]);
System.out.println("The Determinant of 2 * 2 Matrix = " + determinant );
}
}