Skip to main content

6.5) Understanding Arrays (cont’d)


Now, this allows you to use variables called person(1), person(2) and person(3) in place of persona, personb, and personc , respectively. For example, you can read in the values from the keyboard to the different variables as:

read *, person(1)
read *, person(2)
read *, person(3)

Then you could output the values to a file as:

open(33, file=’outputheights.dat’)
write(33,*) person(1)
write(33,*) person(2)
write(33,*) person(2)

Loops and arrays together bring real power into programs so let us now put aside arrays for a minute and look at loops and then after that we will join up loops and arrays.