Information Technology

January 2012

Answer Sheet

Section III (Programming) – 45 MARKS

Question 9 – Trace Table & Logic operators

A).  Algorithm

i.  Trace Table ( 6 marks)

A / B
2 / 10
2 / 5
2 / 2

ii.  Alternative operator to DIV is “/” (1 mark)

B).  Logic operator (8 marks)

i.  12 < 16 → TRUE

ii.  10 > 22 → FALSE

iii.  16 < > 14 → TRUE

iv.  22 = 10 → FALSE

TOTAL 15 MARKS

Question 10 – PASCAL PROGRAM

A).  Pascal symbols(4 marks)

i.  ; - terminates each line of code in PASCAL.

ii.  { -used to make comments within the PASCAL program that is more than one line.

iii.  := -an assignment symbol in PASCAL

iv.  . – To indicate the end of the entire program. It comes after the last “end” in a PASCAL program.

B).  The type of error that is highlighted – SYNTAX ERROR(i.e. :=) (1 mark)

C).  Examples of each of the following (using the PASCAL code provided) (5 marks)

i.  A loop – while (i <= 3) do

ii.  An assignment statement – sum := 0; OR sum := sum + 1; OR i := i + 1;

iii.  A declaration – var sum, I : Integer;

iv.  A program header – program SumNumbers;

v.  A condition – (i <= 3)

TOTAL 10 MARKS

Question 11 – ARRAY

A).  Array size is – 4 (four) (1 mark)

B).  The index numbers order to output the letter C A T – 3, 2, 4 (3 marks)

C).  Write (WORDS[4]); ( 2marks)

D).  A fragment of code to search the array for the letter ‘C’(5 marks)

FOR count : = 1 TO 4 DO

IF WORDS [count] = ‘C’ THEN

Write (count);

OR

FOR index : = 1 TO 4 DO

IF WORDS [index] = ‘C’ THEN

Write (index);

E).  A fragment of code to write the letter ‘Z’ into EACH cell of the array.(4 marks)

FOR count : = 1 TO 4 DO

WORDS [count] : = ‘Z’

OR

FOR index : = 1 TO 4 DO

WORDS [index] : = ‘Z’

TOTAL 15 MARKS

Question 12 – Algorithm

A).  PRINT “ Please enter a letter” (1 mark)

B).  READ CHECK (1 mark)

C).  IF CHECK = “A” THEN

PRINT “GOOD” (3 marks)

TOTAL 5 MARKS