Quick Test 19: Type

1. What is Type used for?

For typing text on the screen.
For defining a new type of variable.
For making combinations of arrays and records.
For declaring variables of mixed types.


Type b = real;
 ......
b := 3.1;
2. Why doesn't the above code work?

We should use 'Type b: real' instead.
real is already defined.
The syntax is wrong, we should use 'typedef' instead.
Type only specifies a type for variables to be declared later and doesn't create a variable itself.


Type a = array[1..10] of
  record
    ri: record
         x: array[1..10] of real;
         y: array[0..3] of integer;
       end;
    rd: record;
         v: real;
         w: double;
       end;
  end;
Var b: a;
3. How to assign a value of 0 to a (the first) y of this program?

4. What will be the output of the next code?
Type floats = array[1..10] of real;

PROCEDURE WriteIt(r: floats);
begin
  WriteLn(r[1]);
end;

Var x: array[1..10] of integer;

begin
  x[1] := 3;
  WriteIt(x);
end.

Undetermined. We forgot to initialize the array r!
3.0
Nothing; type mistmatch in calling the procedure.
3