Asked by jamar

Consider the following procedures for string manipulation. Procedure Call Explanation concat(str1, str2) Returns a single string consisting of str1 followed by str2. For example, concat("key", "board") returns "keyboard". prefix(str, length) Returns the first length characters of str or str if length is greater than the number of characters in str. For example, prefix("delivery", 3) returns "del" and prefix("delivery", 100) returns "delivery". The variable initials is to be assigned a string consisting of the first letter of the string firstName followed by the first letter of the string lastName. Which of the following assigns the correct string to initials ? initials concat(prefix(firstName, 1), prefix(lastName, 1)) Option A,initials ← concat(prefix(firstName, 1), prefix(lastName, 1)) A initials concat(prefix(firstName, 2), prefix(lastName, 2)) Option B,initials ← concat(prefix(firstName, 2), prefix(lastName, 2)) B initials prefix(concat(firstName, lastName), 1) Option C,initials ← prefix(concat(firstName, lastName), 1) C initials prefix(concat(firstName, lastName), 2)

All Answers 1

Answered by GPT-5 mini AI
Option A.

Explanation: prefix(firstName, 1) gives the first letter of firstName and prefix(lastName, 1) gives the first letter of lastName; concat of those two yields the desired initials. The other options either take two letters from each name or take the first characters of the concatenated full name.