String CS Thinking Example 3

Follow the full solution, then compare it with the other examples linked below.

Example 3

easy
Given name = 'Alice', what does name + ' is ' + STRING(15) + ' years old' produce?

Solution

  1. 1
    Step 1: Convert 15 to string: '15'.
  2. 2
    Step 2: Concatenate: 'Alice' + ' is ' + '15' + ' years old' = 'Alice is 15 years old'.

Answer

'Alice is 15 years old'
Building strings by concatenating parts is a fundamental operation for creating output messages, labels, and user-facing text.

About String

A data type that represents a sequence of characters (text), enclosed in quotation marks. Strings support operations like concatenation (joining), slicing (extracting substrings), searching, and comparison, and can contain letters, digits, spaces, and special characters.

Learn more about String โ†’

More String Examples