ExamBank Scot · Higher Computing Science question bank · All Higher Computing Science questions

Higher Computing Science 2019 Question 2

2 marks · Pre-defined functions

A string variable called month has been assigned the value ‘April’ and another string variable called year has been assigned the value ‘2019’ as shown below. Line 1 DECLARE month INITIALLY "April" Line 2 DECLARE year INITIALLY "2019" Line 3 The variable shortDate is to be assigned the value ‘Apr19’ using substring operations. Using a programming language of your choice write line 3.

Marking scheme

• Both substrings • Assignment and concatenation 1 mark for each bullet Examples: shortDate = left(month,3) & right(year,2) shortDate = mid(month, 1, 3) & mid(year,3,2) shortDate = month[0:3] + year[2:4] shortDate = month[:3]+ year[2:] OR year[-2:] shortDate = month[1]+ month[2]+ month[3] + year[3]+year[4]

Previous question: Higher Computing Science 2019 Question 1

Next question: Higher Computing Science 2019 Question 3