Types of Errors
Syntax Errors
Syntax errors occur when the code violates the rules of the programming language, such as missing semicolons, incorrect use of operators, or improperly structured statements. These errors prevent the code from running and are usually identified by the compiler or interpreter, which provides feedback on where the issue lies in the code.
Logical Errors
Logical errors occur when the code is syntactically correct but does not produce the expected result. These errors arise from mistakes in the program's logic, such as incorrect conditions in loops or faulty calculations. Logical errors are often more challenging to detect because the code runs without crashing, but it does not behave as intended, leading to incorrect outputs or unintended behaviour.
Runtime Errors
Runtime errors occurs while the program is running. These errors can result from issues like dividing by zero, accessing out-of-bounds array elements, or trying to use null references. Runtime errors cause the program to crash or behave unpredictably and require careful examination of the code's execution to identify the problem.
Last updated