Subsections

- Exercises

# Summary

There are two values having mode `BOOL`. Operators with operands of mode `BOOL` are predeclared in the standard prelude. A conditional clause uses an enquiry clause yielding a value of mode `BOOL`. A case clause uses an enquiry clause yielding a value of mode `INT`. Both conditional and case clauses can be abbreviated. Extended conditional and case clauses can be written using `ELIF` and `OUSE` respectively. Conditional clauses and case clauses are sometimes grouped together and termed choice clauses. Choice clauses are examples of enclosed clauses, and are units.

Here are some exercises which test you on the material covered in this chapter.

## Exercises

4.10
  Which values have the mode `BOOL`? Ans
4.11
  What is the value of each of the following formulæ? Ans
  (a)
    `3 < 4`

  (b)
    `4.0 >= 0.4e1`

  (c)
    `2 < 3 & 3 > 2`

  (d)
    `11 < 2 OR 10 < ABS TRUE`

  (e)
    `NOT TRUE & ABS "A" < ABS "D"`

  (f)
    `NOT(3 > 2 & 3 > 1 OR 10 < 6)`

4.12
  What is wrong with the following (`m` is predeclared):

         IF m>4|print("ok")ELSE print(".")ESAC

  Ans
4.13
  What would be displayed on your screen by the following:

         FOR i TO 10 DO print(ODD i) OD

  Ans
4.14
  Use a conditional clause to print `"Units"` if `m` (which has mode `INT`) is less than `10`, `"Tens"` if it is less than `100`, `"Hundreds"` if it is less than `1000` and `"Too big"` otherwise. Ans
4.15
  Use a case clause to print the value of a card in words. For example, if it is a queen, print `"Queen"`. Ans