String handling operations in a programming language

EasyMedium
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
Question 63
Easy

A developer is writing a routine to generate unique identifiers for university staff members.

The following variables are defined:

department←’Biophysics’ \text{department} \leftarrow \text{'Biophysics'} department←’Biophysics’ surname←’Choudhury’ \text{surname} \leftarrow \text{'Choudhury'} surname←’Choudhury’

The identifier is generated using the expression:

accessCode←SUBSTRING(3,4,department)+SUBSTRING(0,3,surname) \text{accessCode} \leftarrow \text{SUBSTRING}(3, 4, \text{department}) + \text{SUBSTRING}(0, 3, \text{surname}) accessCode←SUBSTRING(3,4,department)+SUBSTRING(0,3,surname)

Assume that:

  • String indices are 0-based (the first character of a string is at index 0).
  • The function SUBSTRING(start,length,str)\text{SUBSTRING}(start, length, str)SUBSTRING(start,length,str) returns a substring of str str\,str starting at the index start start\,start with the specified lengthlengthlength.

What is the resulting value of accessCode\text{accessCode}accessCode?

′physCho′'physCho'′physCho′

′ophyCho′'ophyCho'′ophyCho′

′physChou′'physChou'′physChou′

′Chophys′'Chophys'′Chophys′

String handling operations in a programming language Questions

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