Types of Bugs in Coding

1. Syntax Error

Occurs when the code violates the grammar rules of the programming language.

// Example:
console.log("Hello World") // Missing semicolon

2. Logical Error

Code runs but gives wrong output due to incorrect logic.

// Example:
function isEven(num) {
  return num % 2 === 1; // Incorrect logic
}

3. Runtime Error

Error that occurs during code execution.

// Example:
let x = 5 / 0; // Division by zero

4. Compilation Error

Error prevents the code from compiling (in compiled languages).

// C Example:
#include 
int main() {
  printf("Hello");
  return 0;
}

5. Semantic Error

Code is syntactically correct but does not do what is intended.

6. Interface Error

Error in using external APIs or libraries.

7. Performance Bug

Causes the program to run slower than expected.

8. Security Bug

Creates vulnerabilities, such as SQL injection possibilities.

9. Compatibility Bug

Works in one environment or browser but fails in another.

10. Resource Bug

Related to improper memory or resource usage.

11. Multithreading Bug

Happens in concurrent executions like race conditions.