Monday, October 3, 2016

Transpose matrix

Save   the   matrix  (A)  in  a  file  as  it  is 

 2        3          5
 7       11         0
-1      -13       -17

Print  A  and  transpose  of  A  in matrix  form .

Program coding

Program transpose_matrix
Integer , Dimension ( 3 , 3 ) : : a , b

Write ( * , 11 )  ' Input matrix  A '
11 format  ( / , A16 )

Read ( * , * ) ( ( a ( i , j ) , j = 1 , 3 ) , i = 1 , 3 )

Do i = 1 , 3
    Do j = 1,  3
        b ( i , j ) = a ( j , i )
    End do
End do

Write ( * , 12 ) ' A = '
12 Format ( / , A5 )

Do i = 1 , 3
Write ( * , * ) ( a ( i , j ) , j = 1 , 3 )
End do

Write ( * , 13 ) ' Then transpose of A  = '
13 Format  ( / , A20 )

Write ( * , 14 ) ( (  b ( i , j ) , j = 1 , 3 ) , i = 1 , 3 )
14 Format ( 3I4 , / , 3I4 ,  / , 3I4)


Stop
End

Input  :


Output :


No comments:

Post a Comment