10-AddMultMatrix-Functions
10-AddMultMatrix-Functions
Integer m, n, p, q, ch
Output "implementation of
Matrix Addition &
Multiplication"
Output
"
1. Addition of 2 Matrices
( Condition is :: R1=R2 &
C1=C2
).
2. Multiplication of 2
Matrices ( Condition is
:: R1=C2 & C1=R2
).
Enter Ur Choice
::
"
Input ch
Input m
Input n
Input p
Input q
False True
ch = 1
False True
ch != 2 False True
m=p and n=q
End
addMat
(Integer m, Integer n)
Integer i
Next
i = 0 to m*n - 1
Done
Output "Enter a no."
Input A [ i ]
Next
i = 0 to m*n - 1
Done
Output "Enter a no."
Input B [ i ]
Next
i = 0 to m*n - 1
Done
Input B [ i ]
Next
i = 0 to m*n - 1
Done
Output A[i] + B[i]
End
multMat
(Integer m, Integer n, Integer q)
Integer i, j, k
Next
i = 0 to m*n - 1
Done
Output "Enter a no."
Input A [ i ]
Next
i = 0 to n*q - 1
Done
Output "Enter a no."
Input B [ i ]
Next
i = 0 to m-1
Done
Next
j = 0 to q-1
Done
C [ i*q + j ] = 0
Next
k = 0 to n-1
Done
C [ i*q + j ] = C [ i*q + j ] + A
[ i*n + k ] * B [ k*q + j ]
Next
i = 0 to m*q - 1
Done
Output C [ i ]
End