Quick Test 17, 18: Arrays and Records

1. What is the difference between an array and a record?

An array can store only countable things, whereas a record can store anything.
A record can only store countable things, whereas an array can store anything.
Arrays are for combining variables of different type, records store variables of the same type.
Records are for combining variables of different type, arrays store variables of the same type.

FUNCTION Maximum(a, b: real): real;
var max: real;
begin
  if a>b then max := a else max := b;
 ......
end;
2. How to let this function return the value of max to the calling instruction?

Nothing, this is done automatically.
Maximum := max;
return max;
This function has no output and will not return anything!

Var a: array[1..10] of
  record
    x: record
         z: array[1..10] of real;
         i: array[1..3] of integer;
       end;
    y: record;
         r: real;
         p: double;
       end;
  end;
3. How to assign a value of 0 to (the first) i of this program?

4. We want to make a database with the information of 1000 students with their name and year. We can do this best with a variable

Var a: record
     number: integer;
     name: string;
     year: integer;
end;
Var a: array[1..1000] of
     record
     name: string;
     year: integer;
end;
Var a: record
     number: array[1..1000] of integer;
     name: array[1..1000] of string;
     year: array[1..1000] of integer;
end;
Var a: array[1..1000] of
     record
       name: array[1..1000] of string;
       year: array[1..1000] of integer;
     end;