Download presentation
Presentation is loading. Please wait.
1
Errors in programming
2
Types of Errors Compiler Errors: a.k.a. Syntax Errors
Errors that prevent your program from running, occur as a result of bad syntax Most compiler errors are caused by mistakes that you make when typing code. E.g. Forgetting your colon when assigning a value (:=) For example, you might misspell a keyword, leave out some necessary punctuation, or try to use an if statement without the then keyword. E.g. var testVariable : bolean
3
Compiler Errors ERRORS var phoneNumber : real var age : int phneNumber = if (age GreaterThan 18) puts phoneNumber
4
Types of Errors Runtime Errors
occur while your program runs, usually when your program attempts an operation that is impossible to carry out. E.g. Division by zero E.g. Trying to convert “bob” to an int
5
Runtime Errors ERRORS var speed : real var km : int var hours : int km := 68 hours := 0 speed := km / hours put “Your speed is “ , speed , “kph”
6
Types of Errors Logic Errors
Errors that prevent your program from doing what you intend it to do, producing an unexpected result. E.g. adding when you meant to subtract These errors are the hardest to find and fix because you do not necessarily know what is the cause of the problem
7
Logic Errors var firstName : string var lastName : string var fullName : string lastName := “Simpson” fullName := firstName + “ “ + lastName put “Your full name is “ + fullName firstName has no value yet...
8
Practice: On the moodle is a zip file named broken.t
Download (to USB), fix this code Use 93, 74, 84 as test numbers Your output should look like this EXACTLY
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.