(1914 Views)

We can add, subtract, multiply and divide 2 matrices of multi-dimensions. For that, we take input from the user the number of rows, columns, first matrix elements and second matrix elements. Then we perform multiplication on the matrices entered by the user and store it in some other matrix.

In matrix multiplication, one row element of first matrix is individually multiplied by all column elements and added. Likewise, for every row element same proceedure is followed and we get the elements.

In the above algorithm,

1. We first define three matrices A, B, C and read their respective row and column numbers in variable m, n, p and q.

2. We check if the matrix can be multiplied or not, if n is not equal to q matrix can't be multiplied and an error message is generated.

2. Read matrices A and B.

3. First, start a loop which goes upto m giving row elements of A

Secondly, inside it again start a loop which goes upto p giving row elements of B.

At last, we define a loop which goes upto p giving column element of B

4. Then, we store their corresponding multiplication by sum= sum + A[i][k] * B[k][j], which gets updated each time till k reaches p, which acts as the mathematical formula of multiplication used for matrix.

5.sum is assigned into C[i][j] and likewise, C stores the multiplication result of matrix A and B

0 UpvotesUpvote |
0 DownvotesDownvote |

- Algorithm to find Maximum of 3 numbers [9268 Views]
- Useful Tips for Manual Code Debugging [1972 Views]
- Move from one Activity to another with a swipe action in Android Studio [1426 Views]
- Download DIGITAL SIGNAL PROCESSING by Ashok Ambardar PDF [1798 Views]
- Simple Augmented Reality Android Application Tutorial using Unity and Vuforia SDK [2386 Views]

- How To Win Ludo King Game Every Time [28688 Views]
- Algorithm to find whether number is Armstrong Number or Not [26430 Views]
- Knuth-Morris-Pratt (KMP) Substring Search Algorithm with Java Example [24380 Views]
- Jio Phone hang on LOGO problem Solution - Hard Reset Jio Phone [19446 Views]
- FlowChart and Algorithm to find Whether a Number is Even or Odd [14414 Views]