Menu
Question Index
...


Write a program to multiply the given matrices.

Input (Two Dimensional matrix) Output (Two Dimensional matrix)
-2  -4  3
-1  2   2
5   4   3
and
6   7   8
1   2   3
4   5   6
-4  -7  -10
4   7   10
46  58  70
4   5   1
7   19   23
and
4   5
7   19
11  6
62   121
414   534
-5   -6
-7   8
and
3   5
-1   -2
-4   -5
null
{}(EMPTY ARRAY)
and
{}(EMPTY ARRAY)
null
null
and
{{1, 2}, {2, 1}}
null
{{1, 2}, {2, 1}}
and
{}(EMPTY ARRAY)
null
null
and
null
null

class AdvanceMatrixMultiplication

{    public static void main(String s[])
    {
        int firstArray[][] = {{-2, -4, 3}, {-1, 2, 2}, {5, 4, 3}};
        int secondArray[][] = {{6, 7, 8}, {1, 2, 3}, {4, 5, 6}};
        int multiplicationArray[][] = multiplyMatrices(firstArray, secondArray);
        if (multiplicationArray != null) {
        System.out.println("Resultant matrix is :");
        for (int[] array1d : multiplicationArray) {
        for (int element : array1d) {
        System.out.print(element + "   ");
        }
        System.out.println();
        }
        } else {
        System.out.println("The matrix multiplication can not be performed due to invalid input data.");
        }

    }


public static int[][] multiplyMatrices(int firstMatrix[][], int secondMatrix[][]) {
//Write code here to get the multiplication of given matrices and return the resultant matrix.
}
}

Doubts

Problems

Topic: Learn Arrays And Loops

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App