10 A function is declared using pseudocode.
FUNCTION ConvertToCm(Inches: REAL) RETURNS REAL
RETURN Inches * 2.4
ENDFUNCTION
Tick () one box which accurately describes the use of the variable Inches
A answer
B call
C parameter
D response
[1]
© UCLES 2020 2210/02/SP/23
8 The function LENGTH(Phrase)calculates the length of a string Phrase
(a) Write the pseudocode statements to:
• store the string "The beginning is the most important part" in Phrase
• calculate and output the length of the string
• output the string in upper case.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
(b) Write the output your pseudocode should produce.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
© UCLES 2023 2210/21/M/J/23
11 The variables P and Q are used to store data in a program. P stores a string. Q stores a character.
(a) Write pseudocode statements to declare the variables P and Q, store "The world" in P and
store 'W' in Q
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
(b) Write a pseudocode algorithm to:
• convert P to upper case
• find the position of Q in the string P (the first character in this string is in position 1)
• store the position of Q in the variable Position
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
(c) Give the value of Position after the algorithm has been executed with the data in
question 11(a).
...................................................................................................................................................
............................................................................................................................................. [1]
© UCLES 2023 2210/22/M/J/23 [Turn over
7 The string operation SUBSTRING(Quote, Start, Number) returns a string from Quote
beginning at position Start that is Number characters long. The first character in Quote is in
position 1.
Write pseudocode statements to:
• store the string "Learning Never Exhausts The Mind" in Quote
• extract and display the words "The Mind" from the string
• output the original string in lower case.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [5]
8 Explain why a programmer would use procedures and parameters when writing a program.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [4]
© UCLES 2023 2210/22/O/N/23
2 Four descriptions of programming concepts and five programming concepts are shown.
(a) Draw one line to link each description to the most appropriate programming concept.
Not all programming concepts will be used.
Description Programming concept
function
a subroutine that may not return a value
procedure
a value that is declared and used within a
specific procedure
parameter
a value that a procedure expects you to
supply when it is called
global variable
a subroutine that will always return a value
local variable
[4]
(b) Write the pseudocode to use a procedure named Average that passes the values 25 and 50
to the procedure.
...................................................................................................................................................
............................................................................................................................................. [2]
(c) Outline the role of procedures and functions in creating a program that is easier to maintain.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
© UCLES 2024 2210/21/M/J/24
(b) The function LENGTH(X) calculates the length of a string X
Write the pseudocode statements to:
• read the contents of the text file Quotation.txt into an appropriate string variable that
has been declared
• output the string in upper case and the length of the string.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
© UCLES 2024 2210/21/M/J/24
10 The function LENGTH(X) calculates the length of a string X
Write the pseudocode statements to:
• allow a line of text to be input to an appropriate variable
• store this line of text in a text file called Main.txt
• calculate the length of the line of text and output the text in lower case along with its length
• store the lower-case line of text in a text file called Lowercase.txt
Make sure that any variables used are declared and that both text files are closed after they have
been used.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [6]
© UCLES 2024 2210/22/O/N/24 [Turn over
2 Tick (3) one box to show how a value can be passed to a procedure.
A function
B parameter
C return
D subroutine
[1]
10 The variables X, Y and Z are used in a program: X stores a whole number, Y stores a decimal
number and Z stores a flag that can be set to TRUE or FALSE
(a) Write pseudocode statements to declare the variables X, Y and Z
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
(b) The function Same(A,B) returns TRUE if the value of A is the same as the value of B when B
is rounded to the nearest whole number and FALSE otherwise.
Write pseudocode statements to:
• define the function
• call the function with X and Y and store the return value in Z
Function definition ....................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Function call .............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[6]
(c) State the difference between defining and calling a function.
...................................................................................................................................................
............................................................................................................................................. [1]
© UCLES 2023 0478/22/F/M/23