Subtract Two Matrix Using Multi-dimensional Arrays in Java

In this program, you will learn to Subtract Two Matrix Using Multi-dimensional Arrays . This is done by using a for loop statement.In this program we are going to calculate the subtraction 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 subtraction both the matrix. The both matrix will be subtracted 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

Subtract Two Matrix Using Multi-dimensional Arrays

When you run the program, the output will be:

Subtraction of A,B : 
69    55    54    57    88    
26    31    93    47    26    
22    68    92    74    36    
81    46    5     59    50    

أحدث أقدم