String handling operations in a programming language

EasyMedium
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
Question 16
Easy

An algorithm is shown in the pseudocode below.

1  cities ← ['Tokyo', 'London', 'Paris']
2  city1 ← 'Berlin'
3  city2 ← 'Madrid'
4  OUTPUT city1
5  OUTPUT LEN(cities)
6  result ← SUBSTRING(1, 4, city2)
7  OUTPUT result

SUBSTRING returns a portion of a string containing the characters from the start index to the end index inclusive (using 0-based indexing). For example, SUBSTRING(1, 3, 'Python') will return the string 'yth'.

State the output of line 7 from this algorithm.

[1]

String handling operations in a programming language Questions

  1. GCSE
  2. /Computer Science
  3. /String handling operations in a programming language