Question 3 2017 · May-June · Paper 23 · 11 marks
Reveal official mark-scheme answer
Official answer for Question 3
Question 11
Show text version of question
Question 3
This function will form a new string, OutString, from a given string, InString, by:
- removing all non-alphabetic characters
- converting all alphabetic characters to lower case.
For example:
InString = "Good Morning, Dave" OutString = "goodmorningdave"
The first attempt at writing the pseudocode for this function is shown below.
Complete the pseudocode using relevant built-in functions.
For the built-in functions list, refer to the Appendix on page 14.
FUNCTION StringClean(...........................) RETURNS ..........
DECLARE NextChar : ......................................
DECLARE ................................................ : STRING
..................................... //initialise the return string
//loop through InString to produce OutString
FOR n 1 TO .............................. //from first to last
NextChar ............................. //get next character and
NextChar ............................. //convert to lower case
IF ........................................ //check if alphabetic
THEN
........................................ //add to OutString
ENDIF
ENDFOR
............................................//return value
ENDFUNCTION
Question 7
Why this question appears here
92% 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 9608_s17_qp_23.pdf
