AQA GCSE Computer Science Paper 1 (1C), June 2025: Question 11
14 marks · Hard difficulty · Programming
Trace a subroutine findLetter for a word-guessing game and extend the VB.NET program to manage player guesses, call the subroutine, and determine whether the player wins or loses.
Practise this questionQuestion
Question text
11 A word game is being developed using VB.NET.
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
*pp**
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 Function findLetter(word As String, letter
As String, hidden As String) As String
2 Dim newHidden As String = ""
3 For i = 0 To word.Length - 1
4 If word(i) = letter Then
5 newHidden = newHidden + letter
6 Else
7 newHidden = newHidden + hidden(i)
8 End If
9 Next
10 Return newHidden
11 End Function
11.1 The subroutine call findLetter("system", "s", "*y**em") is made.
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 31
11.2 The subroutine call findLetter("system", "s", "*y**em")is made.
What is the value of the variable newHidden when line 6 is first executed?
Shade one lozenge.
[1 mark]
A s
B sys
C sys**m
D system
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 32
11.5 A VB.NET program is being written to determine if a player wins or loses the word
game.
• The player wins if they correctly guess all of the letters in the word within eight
*31*guesses or fewer.
• The player loses if they have had eight guesses and there are still letters remaining
that they have not guessed correctly.
Figure 13 shows the beginning of the program.
Figure 13
Dim word As String = Console.ReadLine()
Dim hidden As String = ""
For i As Integer = 0 To word.Length - 1
hidden = hidden + "*"
Next
Extend the program in Figure 13.
Your program must:
• keep repeating the following until the user has had eight guesses or there are no
asterisks left in hidden
o get the user to enter a letter
o call the findLetter subroutine (from Figure 12)
o update the value of hidden using the value returned from findLetter
o display the new value of hidden
• check if the new value of hidden contains any asterisks
o if there are any asterisks in hidden display the message You lost
o if there are no asterisks in hidden display the message You won
The program you write must not use any built-in routines to check if a string contains
another string/character or to count the number of asterisks.
You should use meaningful variable name(s) and VB.NET syntax in your answer.
The answer grid below contains vertical lines to help you indent your code.
[10 marks]
Dim word As String = Console.ReadLine()
Dim hidden As String = ""
For i As Integer = 0 To word.Length - 1
hidden = hidden + "*"
Next
Mark scheme
Show the mark scheme
Total
Question Part Marking guidance
marks
11 1 Mark is for AO2 (apply) 1
B s;
R. If more than one lozenge shaded
Total
Question Part Marking guidance
marks
11 2 Mark is for AO2 (apply) 1
A s;
R. If more than one lozenge shaded
Total
Question Part Marking guidance
marks
11 3 Mark is for AO2 (apply) 1
C 6;
R. If more than one lozenge shaded
Total
Question Part Marking guidance
marks
11 4 Mark is for AO2 (apply) 1
C sys*em;
R. If more than one lozenge shaded
Marking guidance Total
Question Part
marks
11 5 2 marks for AO3 (design), 8 marks for AO3 (program) 10
Program Design
Note that AO3 (design) marks are for selecting appropriate techniques to
use to solve the problem, so should be credited whether the syntax of
programming language statements is correct or not and regardless of
whether the solution works.
Mark A for creating a new iteration construct that exists within their
language and inputting a letter within it;
Mark B for the use of a selection structure for both the messages about
winning and losing;
Program Logic
Mark C for an iteration structure that correctly allows a letter to be entered a
maximum of 8 times (I. any reference to exiting the loop based on the
number of asterisks);
Mark D for an iteration structure that exits correctly when there are no
asterisks left in hidden and there is a correct boolean joining operator for
BOTH conditions (See Mark C for second condition);
Mark E for correctly calling the findLetter subroutine within an iteration
structure (even if the parameters are incorrect or missing);
Mark F for including the correct parameters in the correct order when calling
the findLetter subroutine; Note: the middle parameter should match
the variable name their user input has been assigned to.
Mark G for updating the hidden variable with the return value from the call
to findLetter; R. if hidden is re-initialised within the iteration structure
Mark H for correctly checking to see if there are any asterisks left in
hidden and handling it appropriately;
Mark I for displaying the value of hidden after each attempt;
Mark J for displaying You won and You lost in appropriate places
under the correct conditions;
Note to Examiners
If used built in routines to check if a string contains another string/character
or to count the number of asterisks then do not award marks D and H
I. Case
I. Messages or no messages with input statements
I. Gaps/spaces throughout the code, except where to do so would explicitly
alter the logic of the code in a way that makes it incorrect.
Maximum 9 marks if any errors in code.
Note to examiners
In C#/VB.NET examples, explicit variable declarations are not shown. Refer
to the specific language type issues section of the appropriate Marking
Guidance document. Any correct variable declarations in student answers
should be accepted.
C# Example 1 (fully correct)
All design marks are achieved (Marks A and B)
won = false; Part D
for (i = 0; i < 8; i++) { C
letter = Console.ReadLine();
hidden = findLetter(word, letter, hidden); EFG
Console.WriteLine(hidden); I
won = true; Part D
for (j = 0; j < hidden.Length; j++) { Part H
if (hidden[j] == '*') { Part H
won = false; Part H
}
}
if (won == true) { Part D
break; Part D
}
}
if (won == false) { Part J
Console.WriteLine("You lost"); Part J
} else { Part J
Console.WriteLine("You won"); Part J
}
A. Write in place of WriteLine;
I. missing Console.MARKSCHEME – COMPUTER SCIENCE – – JUNE 2025
VB.NET Example 3 (fully correct)
All design marks are achieved (Marks A and B)
won = False Part D
For count = 1 To 8 C
letter = Console.ReadLine()
hidden = findLetter(word, letter, hidden) EFG
Console.WriteLine(hidden) I
If word = hidden Then Part D, H
won = True Part D
Console.WriteLine("You won") Part J
Exit For Part D
End If
Next 31
If won = False Then Part J
Console.WriteLine("You lost") Part J
End If
A. Write in place of WriteLine;
I. missing Console.
How to answer it
Word Game Algorithm: Tracing Subroutines & Writing Game Logic
What this question tests
This question assesses subroutine parameter tracing, loop boundary execution, string indexing, and the ability to implement a complete event/game loop (AO3 Design & Logic) with bounded iterations, subroutine invocation, conditional termination, and custom search routines without relying on forbidden built-in string methods.
The subroutine being traced in Parts 11.1 through 11.4:
Function findLetter (word As String , letter As String , hidden As String ) As String Dim newHidden As String = "" For i = 0 To word.Length - 1 If word(i) = letter Then newHidden = newHidden + letter Else newHidden = newHidden + hidden(i) End If Next Return newHidden End Function All parts call: findLetter("system", "s", "*y**em")
Question 11.1
Tracing Variable Values on First Execution [1 mark]
✅ Correct Answer
B — s
The variable letter holds the string value passed as the second argument: "s" .
🧠 Exam Technique: Parameter Order
- Look at the header: findLetter(word, letter, hidden) .
- Look at the call: findLetter("system", "s", "*y**em") .
- Match by position: 1st is word , 2nd is letter , 3rd is hidden .
- The parameter letter never changes in the subroutine; its value is always "s" .
Question 11.2
Tracing Variable State at a Specific Branch [1 mark]
✅ Correct Answer
A — s
When line 6 ( Else ) is executed for the very first time, newHidden contains "s" .
📐 Step-by-Step Trace
| Iteration | Index i | word(i) = letter ? | Action taken | newHidden |
|---|---|---|---|---|
| 1st | 0 ( 's' ) | 's' = 's' → True | Executes line 5 ( Then ) | "" + "s" = "s" |
| 2nd | 1 ( 'y' ) | 'y' = 's' → False | Line 6 ( Else ) executed! | Value is currently "s" |
❌ Common Errors
- Guessing the starting value "" (empty string) because they assumed the first iteration enters Else . At index 0, word(0) is 's' , so the If branch runs first!
- Confusing the value of newHidden with hidden .
Question 11.3
Loop Iteration Count [1 mark]
✅ Correct Answer
C — 6
The loop iterates exactly 6 times.
💡 Key Knowledge: Zero-Indexed Loops
- The string passed to word is "system" .
- word.Length = 6.
- The loop header is For i = 0 To word.Length - 1 → For i = 0 To 5 .
- Values taken by i : 0, 1, 2, 3, 4, 5 (exactly 6 iterations, one for each character in the word).
Question 11.4
Subroutine Return Value [1 mark]
✅ Correct Answer
C — sys*em
The function returns the updated hidden string with all occurrences of 's' revealed.
📐 Tracing the Full Loop
| i | word(i) | hidden(i) | Matched 's' ? | Char added | newHidden |
|---|---|---|---|---|---|
| 0 | s | * | Yes | s | s |
| 1 | y | y | No | hidden(1) = y | sy |
| 2 | s | * | Yes | s | sys |
| 3 | t | * | No | hidden(3) = * | sys* |
| 4 | e | e | No | hidden(4) = e | sys*e |
| 5 | m | m | No | hidden(5) = m | sys*em |
Question 11.5
Extended Program: Game Loop Implementation [10 marks]
🧠 The Examiner's Constraint Trap: Read Carefully!
The prompt states: "The program you write must not use any built-in routines to check if a string contains another string/character or to count the number of asterisks."
If you use methods like hidden.Contains("*") or hidden.IndexOf("*") , you immediately lose Marks D and H (a 2-mark penalty)!
Clever observation: If the word has no asterisks left, then hidden = word ! Comparing If hidden = word Then solves the whole problem without any built-in string functions!
✅ Model Solution (AQA Mark Scheme Approved)
' Already provided in Figure 13: Dim word As String = Console.ReadLine() Dim hidden As String = "" For i As Integer = 0 To word.Length - 1 hidden = hidden + "*" Next ' --- Student extension begins here --- Dim won As Boolean = False Dim letter As String For count As Integer = 1 To 8 letter = Console.ReadLine() hidden = findLetter (word, letter, hidden) Console.WriteLine(hidden) ' Check if all letters guessed WITHOUT built-in search methods If hidden = word Then won = True Exit For End If Next If won = True Then Console.WriteLine( "You won" ) Else Console.WriteLine( "You lost" ) End If 💡 Alternative Approach: Character-by-Character Inspection
If you didn't think of hidden = word , you can manually iterate through hidden using a nested loop to check for asterisks:
Dim hasAsterisk As Boolean = False For j As Integer = 0 To hidden.Length - 1 If hidden(j) = "*" Then hasAsterisk = True End If Next If hasAsterisk = False Then won = True Exit For End If Full 10-Mark Breakdown
- Mark A: Iteration construct inputting a letter inside.
- Mark B: Selection construct for both win/loss messages.
- Mark C: Allows maximum of 8 guesses.
- Mark D: Exits correctly when no asterisks remain.
- Mark E: Calls findLetter in loop.
- Mark F: Parameters in correct order: (word, letter, hidden) .
- Mark G: Updates hidden with return value.
- Mark H: Valid asterisk check without forbidden functions.
- Mark I: Displays hidden after each guess.
- Mark J: Correct condition displays for "You won" and "You lost" .
❌ Common Traps Where Students Lost Marks
- Re-initialising hidden : Writing hidden = "" inside the loop wiped out previous correct guesses on each iteration (Mark G lost).
- Parameter order mix-up: Calling findLetter(letter, word, hidden) instead of (word, letter, hidden) (Mark F lost).
- Using forbidden methods: Using hidden.Contains("*") lost Marks D and H simultaneously.
- Early termination without check: Only checking for a win after all 8 guesses had finished, meaning a player who won on guess 3 was forced to guess 5 more times.
Topics
3.1 Fundamentals of algorithms · 3.2 Programming · 3.1.1 Representing algorithms · 3.2.2 Programming concepts · 3.2.7 Input/output · 3.2.8 String handling operations in a programming language · 3.2.10 Structured programming and subroutines (procedures and functions)
Question and mark scheme from the AQA GCSE Computer Science examination, Paper 1 (1C), June 2025. QuestionVault is an independent revision resource; questions remain the copyright of the awarding body.