C234567

       WRITE (6, 39)

       WRITE (6, 40)

       WRITE (6, 41)

       WRITE (6, 42)

  39   FORMAT (1X, ' This program will get 3 integers from the user.')

  40   FORMAT (1X, ' It will echo them out. ')

       WRITE (6, 17)

  41   FORMAT (1X, ' It will then arrange them into descending order.')

  42   FORMAT (1X, ' It will print the sorted numbers.')

       WRITE (6, 17)

  17   FORMAT (1X, '    ')

       CALL GET3 (NUM1, NUM2, NUM3)

       WRITE (6, 17)

       WRITE (6, 43)

  43   FORMAT (' ', ' Here are the 3 numbers input by the user ')

       CALL PRIN3 (NUM1, NUM2, NUM3)

       CALL SORT3 (NUM1, NUM2, NUM3)

       WRITE (6, 17)

       WRITE (6, 44)

  44   FORMAT (' ', ' Here are the 3 numbers in descending order ')

       CALL PRIN3 (NUM1, NUM2, NUM3)

       STOP

       END

 

       SUBROUTINE GET3 (GA, GB, GC)

       INTEGER GA, GB, GC

 

       WRITE (6, 12)

       WRITE (6, 28)

       READ (5, 13,ERR = 25) GA, GB, GC

       GOTO 38

   25  WRITE (6, 14)

   12  FORMAT (1X, ' Please enter 3 integers which are ')

   28  Format (1X, ' right justified in columns 5,10,15 ')

   13  FORMAT (3I5)

   14  FORMAT (1X, //,'  INPUT DATA WAS ERRONEOUS - OUTPUT MEANINGLESS')

   38  RETURN

       END

       

       SUBROUTINE SWAP2(IA, IB)

       ITEMP = IA

       IA    = IB

       IB    = ITEMP

       RETURN

       END

       

       SUBROUTINE SORT3 (MA, MB, MC)

       IF (MA .LT. MB) CALL SWAP2 (MA, MB)

       IF (MB .LT. MC) CALL SWAP2 (MB, MC)

       IF (MA. LT. MB) CALL SWAP2 (MA, MB)

       RETURN

       END

 

       SUBROUTINE PRIN3 (PA,PB,PC)

       INTEGER PA, PB,PC

 

       WRITE (6, 29) PA, PB, PC

  29   FORMAT (1X, I20, I20, I20)

       RETURN

       END
