# Fortran Program for transpose of matrix and check whether it is symmetric or not

Symmetric Matrix : Any square matrix is said to be symmetric if its transpose is equal to its matrix itself.

let A be the square matrix of 3X3 order and AT be its transpose matrix, then the condition for matrix to be symmetric is:

AT = A

If that condition is failed, then the matrix A is said to be anti-symmetric matrix.

Transpose of Matrix: The transpose of matrix A is defined as AT and can be formed by interchanging the row and column of that matrix.

So, If Here is some example of symmetric matrix: ## Fortran Program

! fortran program to check the symmetricity of matrix
program symmetric
implicit none
integer, dimension(3,3) :: matA, matB	! checking for 3X3 matrix
integer :: i, j
character(len=2) :: ans			! variable ans is created

! asking the elements of matrix A
do i = 1,3
do j = 1, 3
print*, "Enter"
end do
end do

!b = transpose(a)			! intrinsic function to create matrix

! interchanging row and columns to find transpose
do i = 1, 3
do j=1,3
matB(j,i) = matA(i, j)
end do
end do

!-----------------------------------------
! you can use intrinsic function transpose() to create transpose on the go
! matB = transpose(matA)
!----------------------------------------

!-----------printing both matrices[optional]------------
print*,"----------------matrixA---------------"			!
do i = 1,3												!
print*, (matA(i, j), j=1,3)							!
end do													!
!
print*,"--------transpose of matrix A---------"			!
do i = 1,3												!
print*, (matB(i, j), j=1,3)							!
end do													!
!-------------------------------------------------------

! checking symmetric or not
do i = 1, 3
do j = 1, 3
if(matA(i,j) /= matB(i,j)) then
ans="n"
exit		! exit terminates these loop if condition failed
end if
end do
end do

! printing the final ans
if (ans == "n") then
print*, "Given matrix is not equal to its transpose"
print*, "Therefore, the matrix is antisymmetric"
else
print*, "Given matrix is equal to its transpose"
print*,"Therfore, the matrix is symmetric"
end if

end program