Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1CALL ShowMenu() | AOne large subroutine with a vague name does many jobs, so it is hard to read and an error is hard to locate. Split it into small subroutines with descriptive names. | |
| 2OUTPUT CalcTotal(5, 3) | BFUNCTION IsPassMark(Score : INTEGER) RETURNS BOOLEAN | |
| 3A descriptive name shows the purpose of a subroutine, so a reader understands it without reading its code | CNames like P1 and P2 do not show purpose, so other programmers working on different subroutines cannot tell what each one does. Use descriptive names such as ReadMarks. | |
| 4A short main program can read like a list of steps because each step is a named subroutine | DTests one subroutine alone by giving it known inputs and checking the output is what you expect | |
| 5PROCEDURE DoStuff() // 80 lines: input, maths and output ENDPROCEDURE | ECALL GetScores() CALL ShowResults() | |
| 6PROCEDURE P1() PROCEDURE P2() | FA main program line that reads like a step in a list and tells the reader what happens without showing the detail |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
modular program — A program split into small named subroutines. Each one can be tested alone and read quickly, so errors are easier to find and the whole program is easier to understand.CALL ShowMenu()
CALL GetChoice()
CALL ShowResult()FUNCTION IsEven(N : INTEGER) RETURNS BOOLEAN
RETURN N MOD 2 = 0
ENDFUNCTION// Test: Square(5) should give 25
OUTPUT Square(5)PROCEDURE DisplayScore(Score : INTEGER)
OUTPUT "Score: ", Score
ENDPROCEDUREFUNCTION IsPass(M : INTEGER) RETURNS BOOLEAN
RETURN M >= 50
ENDFUNCTION