AQA GCSE Computer Science Paper 1 (1A), June 2025: Question 11

14 marks · Hard difficulty · Programming

Trace a C# subroutine for a word-guessing game (parts 11.1–11.4) and write an extended C# program to manage game turns, subroutine calls, and win/loss conditions (part 11.5).

Practise this question

Question

Question 11 presents a C# word-guessing game. Figure 12 shows a subroutine 'findLetter(word, letter, hidden)' which iterates through a word, replacing asterisks in the hidden string with the guessed letter where matches occur. Parts 11.1 to 11.4 are multiple-choice questions asking to trace the values of variables 'letter' and 'newHidden', the number of loop iterations, and the final return value for the call findLetter("system", "s", "*y**em"). Part 11.5 is a 10-mark programming task where students must extend starter code in Figure 13 to create a loop allowing up to 8 guesses, taking letter inputs, calling findLetter, displaying the updated hidden word, and outputting 'You won' or 'You lost' without using built-in string searching or counting routines.
Question text

11 A word game is being developed using C#.

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 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.

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.

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.

*31*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 34

11.5 A C# 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

*32*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

string word = Console.ReadLine();

string hidden = "";

for (int i = 0; i < word.Length; i++) {

hidden = hidden + "*";

}

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 C# syntax in your answer.

The answer grid below contains vertical lines to help you indent your code.

[10 marks]

string word = Console.ReadLine();

string hidden = "";

for (int i = 0; i < word.Length; i++) {

hidden = hidden + "*";

}

Mark scheme

Show the mark scheme Mark scheme for Question 11 gives answers for parts 1 to 4: 11.1 is B (s), 11.2 is A (s), 11.3 is C (6), and 11.4 is C (sys*em), each worth 1 mark. Part 11.5 provides 10 marks total (2 marks for AO3 design and 8 marks for AO3 programming logic), detailing criteria for iteration structure, condition handling without built-in string methods, correctly calling findLetter, updating and displaying hidden, and checking win/loss states, alongside example C# and VB.NET implementations.

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 Guessing Game: Tracing Subroutines & Writing Game Logic

What this question tests

Tracing C# string and loop execution (subroutine parameter passing, variable mutation, iteration count, and return values) and developing a complete console-based game loop in C# using iteration, selection, subroutine calls, manual string searching without built-in methods, and appropriate user output.

Reference Code: findLetter 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 }

Given call for 11.1 – 11.4: findLetter("system", "s", "*y**em")

Question 11.1 • 1 Mark

Value of letter on First Execution of Line 4

Identifying parameter values inside a subroutine

✅ Correct Answer

B: s

💡 Key Knowledge

  • Parameters map by position:
    word = "system"
    letter = "s"
    hidden = "*y**em"
  • The parameter letter does not change anywhere inside the subroutine.
Question 11.2 • 1 Mark

Value of newHidden when Line 7 is First Executed

Tracing execution flow and conditional branches

✅ Correct Answer

A: s

📐 Step-by-Step Trace

  1. Line 2: newHidden = ""
  2. Line 3 (i = 0): word[0] is 's' .
  3. Line 4: "s" == "s" is True.
  4. Line 5: newHidden = "" + "s" = "s" . Line 7 is skipped.
  5. Line 3 (i = 1): word[1] is 'y' .
  6. Line 4: "y" == "s" is False.
  7. Line 7 is executed: Current value of newHidden is still "s".

❌ Common Errors

Thinking line 7 executes on the first loop iteration ( i = 0 ). Because the condition in line 4 is true at i = 0 , the else block is not reached until i = 1 .

Question 11.3 • 1 Mark

Iteration Count of the For Loop

Determining loop bounds

✅ Correct Answer

C: 6

💡 Key Knowledge

  • word = "system"
  • word.Length is 6.
  • The loop runs: for (int i = 0; i < 6; i++) .
  • Values of i : 0, 1, 2, 3, 4, 5 → exactly 6 iterations.

❌ Common Trap

Selecting 7 by confusing zero-indexed upper bounds (< 6 stops when i becomes 6, meaning 6 executions: 0 to 5 inclusive).

Question 11.4 • 1 Mark

Return Value of Subroutine Call

Tracing the full subroutine algorithm

✅ Correct Answer

C: sys*em

📐 Full Trace Table

i word[i] word[i] == "s"? Character appended newHidden
0's'Yes's' (letter)"s"
1'y'No'y' (hidden[1])"sy"
2's'Yes's' (letter)"sys"
3't'No'*' (hidden[3])"sys*"
4'e'No'e' (hidden[4])"sys*e"
5'm'No'm' (hidden[5])"sys*em"

Returns "sys*em" at line 11.

Question 11.5 • 10 Marks

Writing the Full Word Game Program Extension

C# programming: loops, manual checks, subroutine calls, and conditionals

💡 Task Requirements & Restrictions

  • Repeat until 8 guesses are used OR no asterisks remain in hidden .
  • Input a letter from the user.
  • Call findLetter(word, letter, hidden) and update hidden with the returned value.
  • Output the updated hidden string after each guess.
  • CRITICAL RESTRICTION: Must NOT use built-in string functions like .Contains("*") or .Count() . You must manually check characters using a loop!
  • Output "You won" if solved, or "You lost" if out of guesses with asterisks remaining.

✅ Model Solution (C#)

// Continuation from Figure 13 bool won = false; for (int guess = 0; guess < 8; guess++) { string letter = Console.ReadLine(); hidden = findLetter(word, letter, hidden); Console.WriteLine(hidden); // Manually check if any asterisks remain (built-in methods forbidden) won = true; for (int j = 0; j < hidden.Length; j++) { if (hidden[j] == '*') { won = false; } } // Exit early if the player has guessed all letters if (won == true) { break; } } if (won == true) { Console.WriteLine("You won"); } else { Console.WriteLine("You lost"); }

📐 Mark Breakdown (10 Marks Total)

AO3 Design (2 Marks):
• Mark A: Creating a new iteration construct that exists in their language and inputting a letter within it.
• Mark B: Use of a selection structure for both the winning and losing messages.
AO3 Program Logic (8 Marks):
• Mark C: Iteration structure that allows letter to be entered a maximum of 8 times.
• Mark D: Iteration structure exits correctly when no asterisks left, with correct boolean logic.
• Mark E: Correctly calling findLetter within the loop.
• Mark F: Passing correct parameters in order: (word, letter, hidden) .
• Mark G: Updating hidden with return value (reject if reinitialised inside loop).
• Mark H: Correctly checking for asterisks manually without built-in methods.
• Mark I: Displaying hidden after each guess.
• Mark J: Displaying "You won" and "You lost" under the correct conditions.

❌ Common Errors & Lost Marks

  • Using built-in routines: Using hidden.Contains("*") immediately forfeits Marks D and H. You must check each character with a loop.
  • Re-initialising hidden : Writing string hidden = "" inside the loop wipes progress on every turn.
  • Incorrect parameter order: Calling findLetter(letter, word, hidden) breaks the subroutine call mark.
  • Wrong loop bounds: Running guess <= 8 starting from 0 gives 9 guesses instead of 8.

🧠 Exam Technique: Flag Variable Pattern

When searching for a character across a string without built-in methods:

  1. Assume the word is complete: won = true .
  2. Iterate through every character: for (int j = 0; j < hidden.Length; j++) .
  3. If any character matches '*' , flip the flag: won = false .
  4. Break or exit when won == true .

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 (1A), June 2025. QuestionVault is an independent revision resource; questions remain the copyright of the awarding body.