String handling operations in a programming language

EasyMedium
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
Question 35
Easy

The SEEK subroutine returns the 1-based index of the first occurrence of a character in a string.

For example:

  • SEEK("A", "GATTACA") would return 2
  • SEEK("C", "GATTACA") would return 6

nucleotide and dnaSeq are variables used in the algorithm below.

dnaSeq ← "GATTACA"
length ← 7
OUTPUT "Enter the nucleotide to find:"
nucleotide ← USERINPUT

Complete the pseudo-code statement to find the index of the first occurrence of the contents of nucleotide in dnaSeq and store this index in the variable index.

You must use the SEEK subroutine in your answer.

index ← _____

[1]

String handling operations in a programming language Questions

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