Computer Science · Oct / Nov 2024 · Paper 22 · Question 10
0478
As printed in the paper
The question as text
The function s| calculates the length of a string 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 Ô~yzÕxÖx • 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 sv¯w×~§ÕxÖx Make sure that any variables used are declared and that both text files are closed after they have been used. [6]
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
One mark per mark point (max six)
For example:
DECLARE LineOfText : STRING
DECLARE LowercaseText: STRING
INPUT LineOfText
OPENFILE Main.txt FOR WRITE
WRITEFILE Main.txt, LineOfText
CLOSEFILE Main.txt
LowercaseText ← LCASE(LineOfText)
OUTPUT LowercaseText, LENGTH(LineOfText)
OPENFILE Lowercase.txt FOR WRITE
WRITEFILE Lowercase.txt, LowercaseText
CLOSEFILE Lowercase.txt
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

