Gauss Elimination Method – Determinant of a Matrix | FORTRAN 95

Fortran Programming - Bottom Science
PROGRAM gauss_eli_det

IMPLICIT NONE
REAL::A(20,20),k1,k2,c=1.
INTEGER::i,j,n,k

PRINT *, "============================================"
PRINT *, "Program to find the determinant of a matrix using Gauss elimination method - [BY - www.BottomScience.com]"
PRINT *, "============================================"

PRINT *,'GAUSS ELIMINATION - DETERMINANT'
PRINT *,'NO. OF ROWS'
READ(*,*)n

PRINT *,'ENTER ELEMENTS'
READ(*,*)((A(i,j),j=1,n+1),i=1,n)

PRINT *,'YOUR MATRIX - '
DO i=1,n
write(*,*)(A(i,j),j=1,n+1)
END DO

DO k=1,n-1
  k1=A(k,k)
  DO i=k+1,n
    k2=A(i,k)/k1
    DO j=k,n+1
      A(i,j)=A(i,j)-(k2*A(k,j))
    END DO
  END DO
END DO

PRINT *,'UPPER TRIANGULAR MATRIX - '
DO i=1,n
write(*,*)(A(i,j),j=1,n+1)
END DO

PRINT *,'DETERMINANT'
DO i=1,n
c=c*A(i,i)
END DO
write(*,*)c

END PROGRAM

Leave a Reply

Your email address will not be published.