Write short note on
A- Syntax error
B- Run Time error
C-Compiler error
A. Syntax Error
Definition: Errors that occur when the code violates the grammatical rules of the programming language.
Example: Missing semicolons, incorrect use of keywords, or unmatched brackets.
Impact: Detected during the compilation phase and prevents the program from executing.
Example Code:
c
Copy
Edit
int x = 10 // Missing semicolon
printf(“Hello, World!”)
B. Run-Time Error
Definition: Errors that occur while the program is being executed, even if it has been successfully compiled.
Example: Division by zero, accessing an array out of bounds, or invalid memory access.
Impact: Causes the program to crash or behave unexpectedly during execution.
Example Code:
c
Copy
Edit
int a = 5, b = 0;
int result = a / b; // Division by zero
C. Compiler Error
Definition: Errors detected by the compiler during the process of converting the source code into machine code. These can include syntax errors, type mismatches, or undefined references.
Example: Using undeclared variables, incorrect type assignments, or calling an undefined function.
Impact: Compilation fails, and no executable file is generated.
Example Code:
c
Copy
Edit
printf(“Value: %d”, x); // ‘x’ is undeclared
Each type of error must be resolved to ensure a functional and error-free program.