Handle strings with built-in operations
Measure a string, extract a substring and change character case using the syllabus routines.
Exam scope and assessment notes
This sequence follows Cambridge IGCSE Computer Science 0478, 2026–2028 syllabus Version 6. It covers section 8.1 (Programming concepts) only. Pseudocode examples use the published Cambridge format; the separate 2029–2031 syllabus is not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers, a browser-based programming workspace and human subject-teacher review remain outstanding.
Before you begin
- Be comfortable following an ordered algorithm and tracing variable values. Each lesson introduces the Cambridge pseudocode form it uses.
Work on paper. Try each question before revealing help, and explain why your method works.
Quick readiness check
How many characters does LENGTH count in a string?
What you will learn
- Use LENGTH to measure a string
- Use SUBSTRING with a start and length
- Use UCASE and LCASE to change case
String routines return new values
LENGTH(Text) returns the number of characters. UCASE(Text) returns uppercase characters and LCASE(Text) returns lowercase characters.
SUBSTRING(Text, Start, Count) returns Count characters starting at Start. In the published Cambridge pseudocode, the first character generally has position 1, although the syllabus notes that a string may start at 0 or 1 in a programming language.
Keep indexes and lengths within bounds
A substring needs a positive start and length in the stated pseudocode. Check that Start + Count − 1 does not exceed the string length.
Case conversion does not change the stored original unless its returned value is assigned back, for example Name ← UCASE(Name).
Pause and explain
In SUBSTRING("Happy Days", 1, 5), what does the final 5 mean?
Worked example
For Text = "StudyForA", find LENGTH(Text), SUBSTRING(Text, 1, 5) and UCASE(Text).
Show the worked solution
- Count nine characters in the string.
- Start at position 1 and take five characters: Study.
- Convert each letter to uppercase.
Answer LENGTH returns 9; SUBSTRING returns "Study"; UCASE returns "STUDYFORA".
Try a topic test
Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.
Test this topic →From guided practice to a new situation
Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.
For Code = "AB-204", find LENGTH(Code) and UCASE(Code).
Give me a hint
Count the hyphen as a character.
Compare my reasoning
- Count A, B, -, 2, 0 and 4.
- There are six characters.
- The letters are already uppercase.
LENGTH is 6; UCASE(Code) is "AB-204".
Look for these in your work
- All characters counted
- Case result
Extract "Days" from "Happy Days" using Cambridge's 1-based positions.
Give me a hint
The D is at position 7 and the word contains four characters.
Compare my reasoning
- Set Start to 7.
- Set Length to 4.
- Use SUBSTRING with both values.
SUBSTRING("Happy Days", 7, 4) returns "Days".
Look for these in your work
- Start position
- Length
A program extracts 3 characters starting at position 8 from a 10-character string. Is the request within bounds? Explain.
Give me a hint
The last position is Start + Length − 1.
Compare my reasoning
- Calculate 8 + 3 − 1 = 10.
- The substring ends at the final character.
- No position exceeds the string length.
Yes; it uses positions 8, 9 and 10, which fit a 10-character string.
Look for these in your work
- Endpoint calculated
- Bounds checked
Common mistakes
- Confusing a substring's start position with its number of characters
- Using a zero-based index in the pseudocode example without stating that convention
- Expecting UCASE to modify the original variable automatically
What can you explain now?
What does LENGTH("Happy Days") return?
Compare with the explanation
10
The space counts as a character.
After trying it yourself, choose your next review. This is your self-assessment.
Your review choice appears on Today. Sign in to sync it across devices.
Make it stick
Which SUBSTRING parameter gives the number of characters to return?
If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.