Skip to content

Course home

String handling operations in a programming language

String handling operations in a programming language

EasyMedium
1234567891011121314151617181920
Question 6

A cryptographic algorithm uses two system variables assigned as follows:

prefix ← 'CYPHER_B'
system ← 'TITAN_VI'

A developer writes the following pseudocode to generate a temporary security key:

idx1 ← POSITION(prefix, 'P')
idx2 ← POSITION(prefix, '_')
length ← idx2 - idx1
key ← SUBSTRING(idx1, length, system)

Assume the following standard string operations:

  • String indexing is 0-based (the first character is at index 0).
  • POSITION(str, char) returns the 0-based index of the first occurrence of char in str.
  • SUBSTRING(start, length, str) returns the substring of str starting at index start with length length.
  • ← represents the assignment operator.

What is the value of key after this pseudocode is executed?

A

’ITA’\text{'ITA'}’ITA’

B

’TAN_’\text{'TAN\_'}’TAN_’

C

’ITAN’\text{'ITAN'}’ITAN’

D

’AN_V’\text{'AN\_V'}’AN_V’

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