next up previous contents
Next: Data Distribution Up: More File IO Previous: More File IO

Solution

  PROGRAM Exam2
   IMPLICIT NONE
   CHARACTER(LEN=20) :: name
   REAL :: mark1, mark2, mark3, mark4
   INTEGER :: error=0
    OPEN(UNIT=4,FILE='MARKS.DAT')
    DO
     READ(UNIT=4,FMT=*, IOSTAT=error) name, mark1, mark2, mark3, mark4
     IF (error < 0) EXIT   ! end of file test
     average = (mark1 + mark2 + mark3 + mark4)/4.0
     WRITE(*,*) name, average
    END DO
    CLOSE (UNIT=4)
   END PROGRAM


next up previous contents
Next: Data Distribution Up: More File IO Previous: More File IO

©University of Liverpool, 1997
Thu May 29 10:11:26 BST 1997
Not for commercial use.