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