Computer Science GCES OCR
-
Cpu Architecture Performance And Embedded Systems Ocr5 主题
-
Primary And Secondary Storage Ocr6 主题
-
Data Storage And Compression Ocr12 主题
-
Units Of Data Storage Ocr
-
Processing Binary Data Ocr
-
Data Capacity And Calculating Capacity Requirements Ocr
-
Converting Between Denary And Binary Ocr
-
Binary Addition Ocr
-
Converting Between Denary And Hexadecimal Ocr
-
Converting Between Binary And Hexadecimal Ocr
-
Binary Shifts Ocr
-
Representing Characters Ocr
-
Representing Images Ocr
-
Representing Sound Ocr
-
Compression Ocr
-
Units Of Data Storage Ocr
-
Networks And Topologies Ocr6 主题
-
Wired And Wireless Networks Protocols And Layers Ocr6 主题
-
Identifying And Preventing Threats To Computer Systems And Networks Ocr2 主题
-
Operating Systems And Utility Software Ocr2 主题
-
Ethical Legal Cultural And Environmental Impact Ocr2 主题
-
Computational Thinking Searching And Sorting Algorithms Ocr3 主题
-
Designing Creating And Refining Algorithms Ocr5 主题
-
Programming Fundamentals And Data Types Ocr5 主题
-
Additional Programming Techniques Ocr7 主题
-
Defensive Design And Testing Ocr6 主题
-
Boolean Logic Diagrams Ocr2 主题
-
Programming Languages And Integrated Development Environments Ides Ocr3 主题
-
The Exam Papers Ocr2 主题
-
Structuring Your Responses Ocr3 主题
Identify Syntax And Logic Errors In Testing Ocr
Exam code:J277
What are syntax errors and logic errors?
-
Syntax errors and logic errors are thoroughly covered earlier in the course, you can find that revision note here
-
A summary of the two error types:
-
Syntax error: An error that breaks the grammatical rules of a programming language and stops it from running
-
Logic error: Incorrect code is used that allows the program to run, but produces an incorrect or undesired output
-
Identify Syntax & Logic Errors in Testing
How can you identify errors?
-
As a result of a syntax error breaking the rules of the programming language, the program will not execute
-
These are easily identifiable as the IDE will provide information about what the error is
-
This is done to help the programmer be able to fix the issue
-
-
To help practise this skill, a selection of program screenshots will be used
The errors
-
In the code below, there is a program which allows the user to enter how many items they wish to add to a shopping list
-
The code then allows the user to
-
Enter their chosen number of items into a list
-
Output the list to the screen
-
-
The code contains 3 syntax errors, highlighted with blue boxes

Error 1
-
Line 3: Missing a second bracket at the end of integer input
-
The error message below is what the IDE provided to help the programmer identify the error
-
A top tip when programming is to look at the line of code above the one given in the error message
-
For example, this error message claims line 6 is the issue, however, the code above line 6 (line 3) is the line that contains the error
-
-

Error 2
-
Line 6: Missing a colon at the end of a for loop, while loop or if statement
-
As mentioned earlier, the error message identifies the line after the actual error
-
The error is on line 6, however, the syntax error message identifies the line below it
-
Always check the line above for any potential errors
-
-

Error 3
-
Line 7: Using == which is used for a comparison instead of a single = to declare a variable
-
This would return the same error as above, this time the user would more easily be able to identify the issue as it is on line 7
-

The fix
-
Once all fixes are in place, the code should appear as follows and the program should execute as intended


Identifying logic errors
-
Logic errors can be slightly more challenging to locate compared to syntax errors
-
This is because the program will still run but will not produce the expected output that the programmer intended
-
The most obvious areas to check for logic errors are:
-
Logical operators (<, >, ==, !=)
-
Boolean operators (AND, OR, NOT)
-
Division by 0
-
-
To help demonstrate this skill, another snippet of program code is used

-
In this example, the incorrect Boolean operator has been used, OR instead of AND
-
The result means the else clause in the if statement would never be caught
Responses