#
Chapter 4

Ex 4.1

  (a)
    `0`
  (b)
    `4.4`
  (c)
    `FALSE`
  (d)
    `TRUE`
  (e)
    `TRUE`
Ex 4.2

  (a)
    `TRUE`
  (b)
    `TRUE`
  (c)
    `FALSE` (the `UPB t[2:]` is `5`

Ex 4.3

  (a)
    `TRUE`
  (b)
    `TRUE`
  (c)
    `TRUE`
  (d)
    `TRUE`. It is inadvisable to created compuound conditions with this sort of complexity simply because the condition is so difficult to understand. You should particularly avoid compound conditions with `NOT` in front of the various parts.
  (e)
    `FALSE`
Ex 4.4

  (a)
    `TRUE`
  (b)
    `4 <= 2`
  (c)
    `a <= b OR b <= c`
  (d)
    `x /= y AND x /= z`

Ex 4.5

         IF x < pi
         THEN print("Yes")
         ELSE print("No")
         FI

Ex 4.6

         FOR i TO 96
         DO
            print(i*3);

            IF i MOD 16 = 0
            THEN print(newline)
            FI
         OD

Ex 4.7
  The second operand of `OREL` is only elaborated if the first yields `FALSE`.

         PROGRAM ex4 7 CONTEXT VOID
         USE standard
         BEGIN
            INT a = 3, b = 5, c = 4;

            IF
               IF a > b
               THEN TRUE
               ELSE b > c
               FI
            THEN print("Ok")
            ELSE print("Wrong")
            FI
         END
         FINISH

Ex 4.8
  The right-hand side of the identity declaration is clearly an abbreviated case clause, so `p` must yield `INT`, not `BOOL`.
Ex 4.9

         PROGRAM ex4 9 CONTEXT VOID
         USE standard
         CASE SIGN x + 2
         IN
            print("x < 0.0"),
            print("x = 0.0"),
            print("x > 0.0")
         ESAC
         FINISH

Ex 4.10
  `TRUE` and `FALSE`
Ex 4.11

  (a)
    `TRUE`
  (b)
    `TRUE`
  (c)
    `TRUE`
  (d)
    `FALSE`
  (e)
    `FALSE`
  (f)
    `FALSE`
Ex 4.12
  You cannot mix full and abbreviated conditional clauses. Replace the vertical bar with `THEN`. Also replace the `ESAC` with `FI`.
Ex 4.13
  `TFTFTFTFTF`
Ex 4.14

         IF m < 10
         THEN print("Units")
         ELIF m < 100
         THEN print("Tens")
         ELIF m < 1000
         THEN print("Hundreds")
         ELSE print("Too big")
         FI

Ex 4.15

         print((card|"Ace","two","three",
                     "four","five","six",
                     "seven","eight","nine",
                     "ten","Jack","Queen",
                     "King"))