Past-paper question · 2005 October-November · Paper 2 · Q34(e)

Question 34(e) 2005 · October-November · Paper 2 · 23 marks

Question 34

Part (e)

Question 34

END PROCEDURE Validate

The function Len(aString) returns the number of characters in aString. For example, if aString = "Computer", Len(aString) = 8.

Question 4

When the procedure is called with Validate("kg") the lines 1, 2, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 21, 22, 24, 25, 26, 12, 26, 27, 28, 29, 30, 32, 33, 34 are executed and the output is Valid string The example test above can be described as shown in Table 2.1. Path Test Data Expected Output 1, 2, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 21, 22, kg Valid string 24, 25, 26, 12, 26, 27, 28, 29, 30, 32, 33, 34 Table 2.1 Using a table similar to Table 2.1, write down the lines that are executed and the output when the procedure is called with

(i)

Validate(".doc");

[4]

(ii)

Validate("m.d");

[7]

(iii)

Validate("j.b.w").

[7]

Question 5

Task 3 [20 marks] This is a design and implementation task. You are to design and create a very simple octal calculator using a high-level language of your choice. An octal calculator can only use the digits 0 to 7. This calculator will allow the user to enter two unsigned octal numbers and will then allow the user to add, subtract, multiply or divide these numbers. In the case of division, the result should be truncated to a whole number. This is equivalent to integer division. The result is to be displayed in octal. To do this you are advised to follow these steps.

Part (e)

Create a set of test data that shows that the operations of addition, subtraction, multiplication

and division work and provide evidence that you have used this data. Screen dumps are acceptable but must show the data entered and the result of the operation.

[5]

Question 7

Question 8

Every reasonable effort has been made to trace all copyright holders where the publishers (i.e. UCLES) are aware that third-party material has been reproduced. The publishers would be pleased to hear from anyone whose rights they have unwittingly infringed. University of Cambridge International Examinations is part of the University of Cambridge Local Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

Reveal official mark-scheme answer

The answer for this question is in the official mark scheme.

Topic relevance

Why this question appears here

82% assigned-topic match · Programming › Constructs

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9691_w05_qp_2.pdf

Keep practising this topic