Unable to open this exercise
A STRING is a sequence of characters. A CHAR stores one character. Storage width depends on encoding; neither declaration is a promise of one byte.
Routine | Example | Result |
|---|---|---|
LENGTH | LENGTH("River") | 5 |
SUBSTRING | SUBSTRING("River",2,3) | "ive" |
UCASE | UCASE("River") | "RIVER" |
LCASE | LCASE("RiVER") | "river" |
UCASE and LCASE work with strings as well as characters. This course and its runner use position 1 for the first character in SUBSTRING; check the convention stated in another system or question. The third argument is the number of characters, not the ending position.
Worked username
For first name Mira and surname Santos, SUBSTRING("Mira",1,1) gives M. Concatenate using &: M & Santos gives MSantos. LCASE converts the whole result to msantos. Converting only the first character would leave the surname's capitals unchanged.
Independent practice
Trace SUBSTRING("COMPUTER",3,4), then apply LCASE. The extracted string is MPUT and the lowercase result is mput. Now use different names in the username exercise.
AI Socratic Tutor
Need guidance? Ask a question or use the hint below.
AI Socratic Tutor is an All-Access Benefit
Unlock step-by-step Socratic hints, algorithm trace table walkthroughs, and error diagnostics for every Cambridge exercise.
You're chatting with an AI tutor, not a person. AI can make mistakes, so double-check its answers.
Application: Whole-string routines
Application: Whole-string routines
- Write UCASE("Good Day") without quotation marks: [Space 1]
- Write LCASE("AlI") without quotation marks: [Space 2]
- LENGTH("Paper 2") is: [Space 3]
Interactive exercises for Module 2 and beyond require an active plan.