Menu
Question Index
...

What will be the output of the following program?

class ArrayOutput
{
    public static void main(String s[])
    {
        int input[][] = {{2, 4, 0},
                    {5, 5, 3},
                    {1, 0, 0}};
        System.out.println("Determinant of given matrix is : " + getDeterminant(input));
    }

    public static int getDeterminant(int matrix[][])
    {
        int result = 0;
        
        result = (matrix[0][0] * (matrix[1][1] * matrix[2][2] - matrix[2][1] * matrix[1][2])
        
                - matrix[1][0] * (matrix[0][1] * matrix[2][2] - matrix[2][1] * matrix[0][2])

                + matrix[2][0] * (matrix[0][1] * matrix[1][2] - matrix[1][1] * matrix[0][2]));
        
        return result;
    }
}


Determinant of given matrix is : 12
Determinant of given matrix is : 7
Determinant of given matrix is : 0
Compilation Error
Runtime Error

Doubts

Problems

Topic: Java Multidimensional Array

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App