// Program
import
java.util.Scanner;
public
class Determinant_3into3_Matrix
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a[][]=new int[4][4];
System.out.println("Enter
elements");
for(int i=1;i<=3;i++)
{
for(int j=1;j<=3;j++)
{
a[i][j]=sc.nextInt();
}
}
System.out.println("3 x 3 Matrix
is");
for(int i=1;i<=3;i++)
{
for(int j=1;j<=3;j++)
{
System.out.print("\t"+a[i][j]);
}
System.out.print("\n");
}
int one=a[1][1]*((a[2][2]*a[3][3])-(a[2][3]*a[3][2]));
int
two=a[1][2]*((a[2][1]*a[3][3])-(a[2][3]*a[3][1]));
int
three=a[1][3]*((a[2][1]*a[3][2])-(a[2][2]*a[3][1]));
int ans=one-two+three;
System.out.println("Determinant of
3 x 3 Matrix is="+ans);
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.