Computer Science GCES EDEXCEL
-
Decomposition And Abstraction Edexcel2 主题
-
Algorithms Edexcel11 主题
-
Follow And Write Algorithms Edexcel
-
Introduction To Programming Concepts Edexcel
-
Basic Programming Concepts Edexcel
-
Variables Constants And Assignments Edexcel
-
Data Structures And Arrays Edexcel
-
Arithmetic Relational And Logical Operations Edexcel
-
Determine Outputs Of An Algorithm Edexcel
-
Types Of Errors Edexcel
-
Standard Sorting Algorithms Edexcel
-
Standard Searching Algorithms Edexcel
-
Algorithm Efficiency Edexcel
-
Follow And Write Algorithms Edexcel
-
Truth Tables Edexcel3 主题
-
Binary Edexcel6 主题
-
Data Representation Edexcel4 主题
-
Data Storage And Compression Edexcel2 主题
-
Hardware Edexcel5 主题
-
Software Edexcel3 主题
-
Programming Languages Edexcel2 主题
-
Networks Edexcel7 主题
-
Network Security Edexcel2 主题
-
Environmental Issues Edexcel1 主题
-
Ethical And Legal Issues Edexcel3 主题
-
Cybersecurity Edexcel2 主题
-
Develop Code Edexcel6 主题
-
Constructs Edexcel4 主题
-
Data Types And Data Structures Edexcel5 主题
-
Operators Edexcel1 主题
-
Subprograms Edexcel2 主题
Types Of Errors Edexcel
Exam code:1CP2
Syntax, Logic & Runtime Errors
-
Designing algorithms is a skill that must be developed and when designing algorithms, mistakes and issues will occur
-
There are three main categories of errors that when designing algorithms a programmer must be able to identify & fix, they are:
-
Syntax errors
-
Logic errors
-
Runtime errors
-
What is a syntax error?
-
A syntax error is an error that breaks the grammatical rules of a programming language and stops it from running
-
Examples of syntax errors are:
-
Typos and spelling errors
-
Missing or extra brackets or quotes
-
Misplaced or missing semicolons
-
Invalid variable or function names
-
Incorrect use of operators
-
Incorrectly nested loops & blocks of code
-
What is a logic error?
-
A logic error is where incorrect code is used that causes the program to run, but produces an incorrect output or result
-
Logic errors can be difficult to identify by the person who wrote the program, so one method of finding them is to use ‘Trace Tables‘
-
Examples of logic errors are:
-
Incorrect use of operators (< and >)
-
Logical operator confusion (AND for OR)
-
Looping one extra time
-
Indexing arrays incorrectly (arrays indexing starts from 0)
-
Using variables before they are assigned
-
Infinite loops
-
What is a runtime error?
-
A runtime error is where an error causes a program to crash
-
Examples of runtime errors are:
-
Dividing a number by 0
-
Index out of the range of an array
-
Unable to read or write a drive
-
Identifying Logic Errors
-
Logic errors can be slightly 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)
-
-
To help demonstrate this skill, a snippet of program code is used

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

-
At first glance, entering normal test data such as 14, the program works as intended
-
Entering erroneous data or boundary test data which is outside of the range would result in the error
-
When entering the age of 21, it still outputs that the user is in secondary school
-

-
Changing the OR to AND corrects the logic error


Worked Example
Dan is writing a program for maths students. To make sure that there are no logic errors in the program, Dan uses a test plan.
Describe what is meant by a logic error. [2]
Answer
-
The error does not prevent the program from running
-
But it does not produce the expected output / it does not do what the programmer intended
-
A reasonable example
Responses