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.
Independent Practice: Lowercase usernames
Read a non-empty first name and surname. Output a username consisting of the first character of the first name followed by the whole surname, all lowercase.
Write a complete program. Read inputs in the stated order. Output only the requested results, one per line, without input prompts. Test with your own values before submitting.
Interactive exercises for Module 2 and beyond require an active plan.
Run code to inspect step-by-step variable trace states.