Past-paper question · 2015 October-November · Paper 33 · Q6

Question 6 2015 · October-November · Paper 33 · 7 marks

Original past-paper question for 6
Original past-paper question for 6
Reveal official mark-scheme answer

Official answer for Question 6

Part (a)

(i)

SumRange

Question 1

✓
ThisInteger1, ThisInteger2, Flag

Question 1

✓
Must be identifiers only …
[2]

Mark scheme 9691_w15_ms_33.pdf →

Show text version of question

Question 6

A
high-level programming language has a built-in function SumRange defined as follows:

SumRange(ThisInteger1 : INTEGER, ThisInteger2 : INTEGER [Flag : CHAR]) RETURNS INTEGER returns the integer value calculated as the sum of all integers between ThisInteger1 and ThisInteger2. The square brackets denote that Flag is optional. It takes values as follows: • 'Y' – denotes both boundary values are to be included • 'N' – denotes both boundary values will not be included If Flag is omitted, both boundary values are included. For example: SumRange(3, 6, 'Y') returns 18 SumRange(3, 6, 'N') returns 9 An error is generated if: • The function is not properly formed, or • ThisInteger2 is less than ThisInteger1

(i)

State the function name and parameters for the above function. Function name .......................................................................................................................... Parameters ............................................................................................................................... ...............................................................................................................................................[2] What value is returned from the following function calls?

(ii)

SumRange(1, 3) ...............................................................................................................................................[1]

(iii)

SumRange("31", "33", 'Y') ...............................................................................................................................................[1]

(iv)

SumRange(1.5, 4.5) ...............................................................................................................................................[1]

(v)

SumRange(4, 7, 'N') ...............................................................................................................................................[1]

(vi)

SumRange(7, 4, 'N') ...............................................................................................................................................[1]

Question 14

Topic relevance

Why this question appears here

82% assigned-topic match · Hardware › Logic gates and logic circuits

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_w15_qp_33.pdf

Keep practising this topic