In this program we are going to make a simple program that will calculate the sum of the matrix.
Sum of Multidimensional Arrays
In this program we are going to make a simple program that will calculate the sum of the matrix.
To make this program run we need to declare two multidimensional array of type int. Firstly calculate the length of the both the arrays. Now we need to make a matrix out of it. To make the matrix we will use the for loop. By making use of the for loop the rows and column will get divide. This process will be performed again for creating the second matrix.
After getting both the matrix with us we need to sum both the matrix. The both matrix will be added by using the for loop. The output will be displayed by using the println() method.
Here is the code of this program:
class MatrixSum{
|