Question 11
AQA Computer Science June 2025 Paper 1A (8525/1A)GCSE4 marks
On the specification
- 11.1
- 3.2 Programming
- 11.2
- 3.2 Programming
- 11.3
- 3.2 Programming
- 11.4
- 3.2 Programming
Question text
11 A word game is being developed using C#. box A word is displayed as a series of asterisks (*) equal to the number of letters in the word. For example, the word apple would be displayed as ***** The player guesses one letter at a time. If the letter is in the word, the letter will replace the asterisk(s) wherever the letter occurs. For example, if the player enters p then the word apple will be displayed as Only lower-case letters are used in the word game. Figure 12 shows a subroutine used in the program for this word game. • Line numbers are included but are not part of the subroutine. Figure 12 1 static string findLetter(string word, string letter, string hidden) { 2 string newHidden = ""; 3 for (int i = 0; i < word.Length; i++) { 4 if (word[i].ToString() == letter) { 5 newHidden = newHidden + letter; 6 } 7 else { 8 newHidden = newHidden + hidden[i]; 9 } 10 } 11 return newHidden; 12} 11.1 The subroutine call findLetter("system", "s", "*y**em") is made. box What is the value of the variable letter when line 4 is first executed? Shade one lozenge. [1 mark] A *y**em B s C sys**m D system 11.2 The subroutine call findLetter("system", "s", "*y**em")is made. What is the value of the variable newHidden when line 7 is first executed? Shade one lozenge. [1 mark] A s B sys C sys**m D system Figure 12 has been included again below. box Figure 12 1 static string findLetter(string word, string letter, string hidden) { 2 string newHidden = ""; 3 for (int i = 0; i < word.Length; i++) { 4 if (word[i].ToString() == letter) { 5 newHidden = newHidden + letter; 6 } 7 else { 8 newHidden = newHidden + hidden[i]; 9 } 10 } 11 return newHidden; 12} 11.3 The subroutine call findLetter("system", "s", "*y**em") is made. Identify how many times the loop would iterate. Shade one lozenge. [1 mark] A 1 B 2 C 6 D 7 11.4 The subroutine call findLetter("system", "s", "*y**em") is made. What value is returned? Shade one lozenge. [1 mark] A s B sy*tem C sys*em D system