Add Two Matrix Using Multi-dimensional Arrays in Java

In this program, you'll learn to add two matrices using multi-dimensional arrays in Java.we are going to calculate the sum of two matrix and containing its rows and columns.

In this program we are going to calculate the sum of two matrix. To make this program, we need to declare two dimensional array of type integer.
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 with C[r][c]= A[r][c]+B[r][c].
The output will be displayed by using the print() method

Add Two Matrix Using Multi-dimensional Arrays


When you run the program, the output will be:

Addition of Matrix A and B : 
79    20    62    46    52    
40    28    75    87    19    
62    75    56    94    82    
92    40    52    74    107    

Previous Post Next Post