Question 3
-
(a) What is:
(i) an array;
(ii) a syntax error?
(b) Write a QBASIC program that will input multiples of three between 1 and 20 into one-directional array and display the output on the screen.
(c) Convert D5FA16 to binary.
Observation
(a) (i) An array is a collection of elements of the same type stored in a single variable.
OR
An array is a data structure with homogeneous element.
OR
An array is a row of values, a column of values or a combination of rows and columns of values
OR
A data structure consisting of a collection of elements (values or variables,) each identified by at least an array index or key.
(ii) A syntax error is an error resulting from violation of grammatical rules of a language.
OR
A syntax error is an error from non-compliant with the grammar of a language.
OR
A syntax error is the syntax of sequence of characters or tokens that is intended to be written in a particular programming language
(b) 10 DIM M(7)
20 PRINT "MULTIPLE OF 3"
30 FOR I = 1 TO 6
40 M(I) = 3 * I
50 PRINT M(I)
70 NEXT I
80 END
OR
10 FOR I = 1 TO 6
20 M(I) = 3 * I
30 PRINT M(I)
40 NEXT I
(c) Converting D5FA16 to binary
D = 1101
5 = 0101
F = 1111
A = 1010
D5FA16 = 11010101111110102
The question tested candidates’ knowledge of computer programming and conversion of number bases.
The chief examiner reported that candidates avoided the question and the few that answered demonstrated poor knowledge of computer programming.