Subsections

- Exercises

# Rows of structures

In the last section, we considered multiples in structures. What happens if we have a multiple each of whose elements is a structure? No problem. If we had declared

       [10]COMPL z4

then the selection `re OF z4` would yield a name with mode `REF[]REAL` and bounds `[1:10]`.8.1 It would be possible, because it is a name, to assign to it:

       re OF z4:=(1,2,3,4,5,6,7,8,9,10)

Selecting the field of a sliced multiple of a structure is straightforward. Since the multiple is sliced before the field is selected, no parentheses are necessary. Thus the real part of the third `COMPL` of `z4` above is given by the expression

       re OF z4[3]

Now consider a multiple of a structure which contains a multiple. Here is its declaration:

       [100]STRUCT(CHAR c,[5]INT i)s

Then the fourth integer in the 25th structure of `s` is given by

       (i OF s[25])[4]

and all the characters are given by the selection

       c OF s

with mode `REF[]CHAR` and bounds `[1:100]`.8.2

## Exercises

7.13
  Suppose a firm had 20 employees, and in writing one of the programs in their payroll system, the modes of section 7.5 were used. Suppose now that we have the declaration

         [20]EMPLOYEE employee;

  What would be the mode of each of the following: Ans
  (a)
    `(dept OF employee[3])[3]`

  (b)
    `dept OF employee[10:12]`

  (c)
    `ni code OF employee[1]`

  (d)
    `net pay OF employee[15]`

  (e)
    `(tax OF employee[2])[50:51]`