6.11) Understanding Loops And Arrays
Or you could join them up together in one loop. As the height is read in it is then output to the file outputheights.dat
before the next height is read:
open(33, file=’outputheights.dat’) do i=1,3 read *, person(i) write(33,*) person(i) enddo
Note that I open the file before trying to write to it or else it won’t work. Also, don’t put the open inside the loop or it will be opened three times!
Please watch the video to see a loop in action.