Learning Intention I will learn about the different
Learning Intention • I will learn about the different types of programming errors.
1. 2. 3. 4. 5. 6. Analysis Design Implementation Testing Documentation Evaluation
Types of Error There are three types of error which can occur when you are creating programs: • syntax • execution • logic
Syntax Errors Syntax errors are sometimes caused by typing mistakes e. g.
Syntax Errors Syntax errors prevent the program from running.
Syntax Errors Syntax errors are sometimes caused by not knowing the syntax (rules) of the programming language e. g.
Execution Errors Execution errors only show up when the program is running and cause it to crash e. g. • divide by zero – dividing a number by 0 gives the answer infinity (∞)which the computer cannot store • opening file that does not exist
Execution Errors Here is an example of code that attempts to divide by zero. Line 1 RECEIVE number 1 FROM KEYBOARD Line 2 SET number 2 TO number 1 / 0 Line 3 SEND number 2 TO DISPLAY
Logic Errors Logic errors cause the program to operate incorrectly but not crash. The program will run but the output will be wrong. e. g. • adding two numbers instead of subtracting • using < instead of <= in a condition (If)
Logic Errors The following program runs but the output will not match what is expected. Line 1 Line 2 Line 3 Line 4 RECEIVE number 1 FROM KEYBOARD RECEIVE number 2 FROM KEYBOARD SET average TO (number 1 + number 2) / 2 SEND average TO DISPLAY Which line has the logic error?
Success Criteria • I can describe and identify the different types of error in a program.
- Slides: 11