The document outlines two main categories of errors in algorithms: syntax errors and logic errors. Syntax errors disrupt the grammatical rules of programming languages, while logic errors allow programs to run but produce incorrect outputs. It also includes examples of each error type and tasks for correction.
The document outlines two main categories of errors in algorithms: syntax errors and logic errors. Syntax errors disrupt the grammatical rules of programming languages, while logic errors allow programs to run but produce incorrect outputs. It also includes examples of each error type and tasks for correction.
Compiled By: Bilal Khan Video https://www.youtube.com/watch?v=F_BiYH9b8 OQ&t=42s
Computer Science 2210
Compiled By: Bilal Khan Main categories of errors: When designing algorithms, mistakes and issues will occur. There are two main categories of errors:
▪ Syntax errors
▪ Logic errors
Computer Science 2210
Compiled By: Bilal Khan ▪ Syntax Errors: A syntax error is an error that breaks the grammatical rules of a programming language and stops it from running. Examples: ▪ Typos and spelling errors ▪ Missing or extra brackets or quotes ▪ Misplaced or missing semicolons ▪ Invalid/incorrect variable or function names ▪ Incorrect use of operators ▪ Incorrectly nested loops & blocks of code Computer Science 2210 Compiled By: Bilal Khan ▪ Logic Errors: A logic error is where incorrect code is used that causes the program to run, but produces an incorrect output or result. Examples: ▪ Incorrect use of operators (< and >) ▪ Logical operator confusion (AND for OR) ▪ Looping one extra time ▪ Using variables before they are assigned ▪ Infinite loops Computer Science 2210 Compiled By: Bilal Khan Task (A): Task (B): Ans: Task (A) a.
b. Ans: Task (B)
• Numbers should be Number
• IF Number > 100 should be IF Number >= 100
• INPUT Number is missing from inside the loop, insert
INPUT Number after the ENDIF statement.
• The final OUTPUT Number is not needed, remove it.