• Practice
  • About 13 min
  • 5 practice questions

Types of errors, languages and paradigms

Differentiate syntax, logical and runtime errors and describe procedural and object-oriented programming.

If something looks wrong, please tell us.

Writing a program is only the first step; you must also find and fix mistakes. This lesson covers the kinds of errors and some key programming terms that appear in papers.

Kinds of errors

Errors
ErrorMeaningFound
Syntax errorBreaks the grammar rules of the languageBefore the program runs, by the translator
Runtime errorHappens while running, such as dividing by zeroDuring execution
Logical errorThe program runs but gives a wrong resultBy testing; no error message appears

Debugging means finding and removing errors. A bug is an error in a program.

Paradigms and terms

  • Procedural programming organises code as procedures or functions run in order.
  • Object-oriented programming (OOP) organises code around objects that combine data and the actions on it. Key ideas are class, object, inheritance, encapsulation and polymorphism.
  • A function is a named block of code that performs a task and can be reused.
  • A comment is a note for humans that the computer ignores.
  • Pseudocode is a plain-language description of an algorithm.

Worked examples

Example 1. A program is meant to compute the average of 2 numbers but uses (A + B) / 3. It runs and prints a value, but the value is wrong. What kind of error? A logical error.

Example 2. A program forgets a closing bracket and cannot be compiled. What kind of error? A syntax error.

Syntax error: breaks the grammar. Runtime error: crashes while running. Logical error: runs but wrong answer.

— Rule to remember

Key takeaways: syntax errors block translation, runtime errors stop execution, logical errors give wrong results.

Check your understanding

  1. 1. A program meant to average two numbers uses (A + B) / 3. It runs and prints a value, but the value is wrong. Which error is this?

    1. Syntax error
    2. Runtime error
    3. Logical error
    4. Hardware fault
    Show answer

    Answer: C. The program runs but gives a wrong result, so it is a logical error.

  2. 2. A program forgets a closing bracket and cannot be compiled. Which error is this?

    1. Syntax error
    2. Logical error
    3. Runtime error
    4. No error
    Show answer

    Answer: A. Breaking the grammar rules of the language is a syntax error, caught by the translator before the program runs.

  3. 3. Dividing a number by zero during execution causes a

    1. Syntax error
    2. Logical error that gives no message
    3. Runtime error
    4. Comment
    Show answer

    Answer: C. An error that happens while the program runs, such as dividing by zero, is a runtime error.

  4. 4. What is a comment in a program?

    1. An instruction the computer runs first
    2. A note for human readers that the computer ignores
    3. A type of syntax error
    4. A loop that never ends
    Show answer

    Answer: B. A comment is a note for humans; the computer ignores it.

  5. 5. Which paradigm organises code as procedures or functions run in order?

    1. Object-oriented programming
    2. Debugging
    3. Pseudocode
    4. Procedural programming
    Show answer

    Answer: D. Procedural programming organises code as procedures run in order. Object-oriented programming organises code around objects.

Sign in to keep track of the lessons you finish.

Next lesson → Programming concepts mixed practice

Privacy · Terms · Refunds · Delivery