Skip to content

Course home

String handling operations in a programming language

String handling operations in a programming language

EasyMedium
1234567891011121314151617181920
Question 9

A program processes sensor calibration data using the following variable assignments:

sensor_id ← 'A-9082-XT_Primary'
mode ← 'HighRes'
calibration ← 'Offset: -12.4'

The following statements are then executed:

x ← SUBSTRING(2, 4, sensor_id)
y ← POSITION(calibration, ':')
result ← x + SUBSTRING(y + 2, 5, calibration)

What is the value of result?

Note:

  • SUBSTRING(start, length, string) extracts a portion of a string starting at the 0-based index start with the specified length. For example, SUBSTRING(1, 3, 'computer') returns 'omp'.
  • POSITION(string, character) returns the 0-based index of the first occurrence of character in string.
  • + performs string concatenation when applied to string values.
A

′9082−12.4′'9082-12.4'′9082−12.4′

B

′−908−12.4′'-908-12.4'′−908−12.4′

C

9069.69069.69069.6

D

′908212.4′'908212.4'′908212.4′

Markscheme

String handling operations in a programming language Questions

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

89 exam-style questions on AQA GCSE Computer Science String handling operations in a programming language. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank