Question 1(c) 2024 · October-November · Paper 41 · 4 marks
Reveal official mark-scheme answer
Official answer for Question 1
Part (c)
Question 1
mark each
Question 4
- Function header (and close where appropriate) taking (min) two parameters and returns a value in all cases
- Looping through each character in each string parameter …
- … return 1 when first parameter second
- … return 2 when first parameter second
Show text version of question
Question 1
Part (c)
Question 1
A program sorts string data using different sorting methods.
Part (c)
The function CompareStrings():
- takes two strings as parameters
- compares each string, one character at a time, to identify which string comes first
alphabetically. If the first two characters are the same, the second character of each string is compared. This continues until the two characters are different.
The function:
- returns 1 if the first parameter comes before the second alphabetically
- returns 2 if the second parameter comes before the first alphabetically.
Write program code for CompareStrings().
Assume that all strings are in lower case.
Assume that a difference between two strings will always be identified before the end of one string is reached.
Do not use an in-built string comparison function.
The strings must be compared one character at a time.
Save your program.
Copy and paste the program code into part 1(c) in the evidence document.
Question 5
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 9618_w24_qp_41.pdf
