Skip to main content

6.10) Loops And Arrays Together


Now we are ready to join up the use of loops and arrays. Now let’s return to the task of entering three heights and printing the values to an output file. I will now show you how loops and arrays can work together to solve this.

       do i=1,3
          read *, person(i)
       enddo

Now you could output the values to a file as:

       open(33, file=’outputheights.dat’)
       do i=1,3
          write(33,*) person(i)
       enddo