program matrix_multiplication
integer::i,j,k,m,n,p
real::a(10,10),b(10,10),c(10,10)
print*,'Enter the order of matrix A:-'
read*,m,n
print*,'Enter the matrix A:-'
do i=1,m
read(*,*)(a(i,j),j=1,n)
enddo
print*,'Enter the order of matrix B:-'
read*,n,p
print*,'Enter the matrix B:-'
do i=1,n
read(*,*)(b(i,j),j=1,p)
enddo
!performing matrix multiplication
do i=1,m
do j=1,p
c(i,j)=0
do k=1,n
c(i,j)=c(i,j)+a(i,k)*b(k,j)
enddo
enddo
enddo
print*,"The multiplied matrix is:"
do i=1,m
write(*,*)(c(i,j),j=1,p)
enddo
end
integer::i,j,k,m,n,p
real::a(10,10),b(10,10),c(10,10)
print*,'Enter the order of matrix A:-'
read*,m,n
print*,'Enter the matrix A:-'
do i=1,m
read(*,*)(a(i,j),j=1,n)
enddo
print*,'Enter the order of matrix B:-'
read*,n,p
print*,'Enter the matrix B:-'
do i=1,n
read(*,*)(b(i,j),j=1,p)
enddo
!performing matrix multiplication
do i=1,m
do j=1,p
c(i,j)=0
do k=1,n
c(i,j)=c(i,j)+a(i,k)*b(k,j)
enddo
enddo
enddo
print*,"The multiplied matrix is:"
do i=1,m
write(*,*)(c(i,j),j=1,p)
enddo
end
Comments
Post a Comment