Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of the following is an illegal array definition?

  • A.Type COLOGNE:(LIME,PINE,MUSK,MENTHOL); var a:array[COLOGNE]of REAL;
  • B.var a:array[REAL]of REAL;
  • C.var a:array['A'..'Z']of REAL;
  • D.var a:array[BOOLEAN]of REAL;

Answer: B

Correct answer: var a:array[REAL]of REAL;

An array index type must be an ordinal type - one whose values can be counted off, so that each has a definite position. Enumerations, characters and booleans all qualify, which is why the other three definitions are legal. REAL is not ordinal: there is no “next” real number, so it cannot index an array.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.