String handling operations in a programming language

EasyMedium
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
Question 18
Easy

A telemetry logging system receives string data from remote environmental sensors. Each data packet is formatted as:

[SensorID]-[Timestamp]-[Reading] (for example, "TEMP01-16982300-23.5")

To process this string, a program first identifies the index of the first hyphen delimiter using the statement:

hyphenPos ← POSITION(telemetry, '-')

Using the standard AQA pseudo-code definition of SUBSTRING(startPosition, length, string), which of the following statements correctly extracts the SensorID substring and assigns it to the variable sensorID?

sensorID←SUBSTRING(1,hyphenPos,telemetry)\texttt{sensorID} \leftarrow \texttt{SUBSTRING}(1, \texttt{hyphenPos}, \texttt{telemetry})sensorID←SUBSTRING(1,hyphenPos,telemetry)

sensorID←SUBSTRING(0,hyphenPos−1,telemetry)\texttt{sensorID} \leftarrow \texttt{SUBSTRING}(0, \texttt{hyphenPos} - 1, \texttt{telemetry})sensorID←SUBSTRING(0,hyphenPos−1,telemetry)

sensorID←SUBSTRING(0,hyphenPos,telemetry)\texttt{sensorID} \leftarrow \texttt{SUBSTRING}(0, \texttt{hyphenPos}, \texttt{telemetry})sensorID←SUBSTRING(0,hyphenPos,telemetry)

sensorID←SUBSTRING(hyphenPos,0,telemetry)\texttt{sensorID} \leftarrow \texttt{SUBSTRING}(\texttt{hyphenPos}, 0, \texttt{telemetry})sensorID←SUBSTRING(hyphenPos,0,telemetry)

String handling operations in a programming language Questions

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