Question Constellation Sign up for free

AQA · GCSE · Computer Science · Higher

Identifying syntax and logic errors

Q03.3 2 marks
Figure 3
5int userNumber = Convert.ToInt32(Console.ReadLine());
6while (userNumber < 1 || userNumber > 100)
7{
8 Console.WriteLine("Invalid number");
9 userNumber = Convert.ToInt32(Console.ReadLine());
10}
11Console.WriteLine("Valid number entered");

Complete the table to describe the errors in the program on line 6.

Practice unavailable

This question can be viewed, but its original response format is not available for practice yet.

Write your answer first. You can study the marking guidance whenever you need it.

Study the marking See what earns credit and compare it with a full-mark answer.

Marking points

  1. 1 Identifies or corrects the misspelling whil.
  2. 2 Identifies or corrects the inclusive upper comparison so 100 remains valid.

Full-mark answer

Syntax error: whil is misspelt and should be while. Logic error: >= 100 rejects 100, so it should be > 100.

Why this answer loses marks

The line has a spelling error and the condition is wrong.

This identifies the error categories but not the misspelt keyword or the boundary that wrongly rejects an allowed input.