MatrixAddition and Multiplication
MatrixAddition and Multiplication
do i=1,m,1
write(*,5) (c(i,j),j=1,n)
end do
else
write(*,*) " Addition of A and B matrix is not possible!"
end if
end program Matrix_Addition
program Matrix_Multiplication
implicit none
integer::i,j,m,n,p,q,k
!real::a(100,100), b(100,100), c(100,100)
real, dimension(100,100):: a,b,c
do i=1,p,1
write(*,5) (b(i,j),j=1,q)
end do
if (n==p) then
write(*,*) "Calculate the Matrix C of order (m by q) by multiplying Matrix A and Matrix B:"
do i=1,m,1
do j=1,q
c(i,j) = 0
do k=1,n
c(i,j)=c(i,j)+a(i,k)*b(k,j)
end do
end do
end do
else
write(*,*) "Matrix multiplication (AB) of A and B is not possible!"
end if
end program Matrix_Multiplication