0% found this document useful (0 votes)
38 views4 pages

9816 - 02 - Status Basic - Program Design - 2024

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views4 pages

9816 - 02 - Status Basic - Program Design - 2024

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1

Status Mock 01-Basic: Program Design

Name: Date: Marks: /50

1. Read the following code.

Paper | 2
FOR Index = 1 TO 10
OUTPUT((Index * 5) DIV 2)
NEXT Index
(a) Tick (✓) one box in each row to identify whether each programming construct has or has not been used
in this program.
Constructs Has been used Has not been used
Sequence
Selection
Iteration
[2]
(b) (i) Give the first three numbers that will be printed by this algorithm.
………………………………………………...………….…………………..…………....[1]
(ii) Line 2 of the program is changed to PRINT (Index + 8).
Give the first three numbers that will now be printed.
………………………………………………....……………………………..…………....[1]
(c) Draw a flowchart to represent this section of program code without changing the output.
…………………..……………...………………………..…………………….……….…….
…………………..……………...………….………………………………….……….…….
…………………..……………...………………………..…………………….……….…….
…………………..……………...………….………………………………….……….…….
…………………..……………...………………………..…………………….……….…….
…………………..……………...………….………………………………….……….…….
…………………..……………...………….………………………………….……….…….
…………………..……………...………………………..…………………….……….…….
………………………..……………...……………………...……………………….……….
……………………………..……………..………………………………..………………[6]
2. Explain why constants, variables and arrays are used in programming.
(a) (i) Constants ………...……………...……………………..…………………….……….…….
……………………………..……………..………………………………..………………[1]
(ii) Variable………...……………...……………..………..…………………….……….…….
……………………………..……………..………………………………..………………[1]
(iii) Array………...…………….....………………………..…………………….……….…….
……………………………..……………..………………………………..………………[1]
(b) Write the name of the computer term being describe below.
is the process of removing unnecessary detail from a problem so that the …………………….
important details can be focused on.
is breaking down a problem /task into smaller sub , more that can be solved on …………..……....[2]
their own.

© HSCICT 2024 9618 / P2 / Status Mock 01 -Basic/ Summer 2024


2
3. Start

count = 1

count <=4 No
?

Paper | 2
Yes

OUTPUT Count * 2

count = count + 1

End

(a) What is the output of the program?


count Output
1
2
3
4
[2]
(b) Describe what the algorithm represented by the flowchart is doing.
…………………………….…………………...……………………………..…………....[1]

4. The algorithms shown have both been written with the intention of printing out the even numbers from
2 to 10 inclusive.

Algorithm A Algorithm B
X = 2 X = 2
WHILE X<>10 DO REPEAT
X = X + 2 X = X + 2
OUTPUT X OUTPUT X
ENDWHILE UNTIL X > 10

(a) State the outputs from


(i) Algorithm A : ……………..……………………………………………...……..………....[1]
(ii) Algorithm B : ………………………………..…………………………...……..………....[1]
(b) Modify
(i) Algorithm A
(ii) Algorithm B so that each will output the even numbers from 2 to 10 inclusive.
…………………..……………...………………………..…………………….……….…….
…………………..……………...………….………………………………….……….…….
…………………..……………...………………………..…………………….……….…….
………………………..……………...……………………...……………………….……….
……………………………..……………..………………………………..………………[2]
(c) Rewrite the above corrected pseudocode 6.(b)using a FOR…NEXT loop.

…………………..……………...………………………..…………………….……….…….
………………………..……………...……………………...……………………….……….
……………………………..……………..………………………………..………………[2]

© HSCICT 2024 9618 / P2 / Status Mock 01 -Basic/ Summer 2024


3

5. The following is a function design in pseudocode. Line numbers are given for reference only.
01 FUNCTION CountDigits(InString : STRING) RETURNS CHAR
02
03 DECLARE nc : CHAR
04 DECLARE c : INTEGER
05 DECLARE n : INTEGER

Paper | 2
06
07
08 C  0
09 N LENGTH(InString) // get number of characters for loop
10
11 WHILE N > 0 // repeat until no more characters left
12
13 nc LEFT(InString,1)
14 n n - 1
15 InString RIGHT(InString,n) // remove first character
16
17 IF (nc < '0') OR (nc > '9')
18 THEN
19 // do nothing
20 ELSE
21 c c + 1
22 ENDIF 23
24 ENDWHILE
25
26 RETURN c
27
28 ENDFUNCTION
(a) (i) This pseudocode includes features that make it easier to read and understand.
State two such features.
………………………..……………...……………….………...……………………….……….
……………………………..……………..…………………………………..………………[2]
(ii) State two additional features that should be used to make this pseudocode easier to read and understand.
………………………..……………...……………….………...……………………….……….
……………………………..……………..…………………………………..………………[2]
(b) There is a mistake in the pseudocode that would produce a data type mismatch error if a programmer were
to write similar program code.
(i) Describe this mistake and how it may be corrected.
…………………..……………...……..…………………..…………………….………..…….
…………………..……………...……………………………………………….………...…….
…………………..……………...……..…………………..…………………….………..…….
…………………..……………...……………………………………………….………...…….
…………………..……………...……..…………………..…………………….………..…….
…………………..……………...……………………………………………….………...…….
…………………..……………...……………………………………………….………...…….
………………………..……………...……………….………...……………………….……….
……………………………..……………..…………………………………..………………[4]

© HSCICT 2024 9618 / P2 / Status Mock 01 -Basic/ Summer 2024


4
(ii) Lines 17 to 22 of the pseudocode could be written in a simplified form.
Re-write the lines in a simplified form.
…………………..……………...……………………………………………….………...…….
…………………..……………...……..…………………..…………………….………..…….
…………………..……………...……………………………………………….………...…….

Paper | 2
…………………..……………...……………………………………………….………...…….
…………………..……………...……………………………………………….………...…….
………………………..……………...……………….………...……………………….……….
……………………………..……………..…………………………………..………………[5]
(c) Study the function CountDigits(). Identify the features of the function in the following table.

Feature Answer

A line number containing an example of an assignment statement

A line number containing the start of a ‘pre-condition’ loop

A line number containing the end of a ‘pre-condition’ loop

A line number containing the start of a selection statement

The number of parameters passed to the LEFT() function

The Boolean operator used

The number of times the function LEFT() is called from within CountDigits()
resulting from the call:
Result CountDigits("AB27C4")

The number of local variables


[8]
6. Study the following pseudocode.
CASE OF MySwitch
1: ThisChar 'a'
2: ThisChar 'y'
3: ThisChar '7'
OTHERWISE: ThisChar '*'
ENDCASE
Write pseudocode with the same functionality without using a CASE structure.
…………………..……………...……..…………………..…………………….……..……..…….
…………………..……………...………………………………………………….………...…….
…………………..……………...…………………………..……………….……….……..….…..
………………………..……………...……………….………...………………………….……….
……………………………..……………..………………………………………………………[4]

© HSCICT 2024 9618 / P2 / Status Mock 01 -Basic/ Summer 2024

You might also like