Monday 28 September 2020

What are the different types of errors in C? Explain with examples.

 Question: What are the different types of errors in C? Explain with examples.

Answer

Errors are the problems or the faults that occur in the program. There are commonly five types of errors exist in C programming:

  1. Syntax error
  2. Run-time error
  3. Linker error
  4. Logical error
  5. Semantic error

Syntax error

Syntax errors are also known as the compilation errors as they occurred at the compilation time. These errors are mainly occurred due to the mistakes while typing when programmer does not follow the grammar rule of the programming language. These errors can be easily corrected.

Commonly occurred syntax errors are: using variable without its declaration, missing the semicolon (;) at the end of the statement.

syntax-error

Run-time error / Execution Error

The errors exist during the execution-time even after the successful compilation known as run-time errors. When the program is running, and it is not able to perform the operation is the main cause of the run-time error. The division by zero is the common example of the run-time error. These errors are very difficult to find, as the compiler does not point out to these errors.

run-time-error

Linker error

Linker errors are mainly generated when the executable file of the program is not created. This can be happened either due to the wrong function prototyping or usage of the wrong header file.

linker-error

Logical error

The logical error is an error that leads to an undesired output. These errors produce the incorrect output, but they are error-free, known as logical errors. The occurrence of these errors mainly depends upon the logical thinking of the developer.

logical-error

Semantic error

Semantic errors are the errors that occurred when the statements are not understandable by the compiler. The following can be the cases for the semantic error:

semantic-error

No comments:

Post a Comment

MCQ Question Bank Microsoft PowerPoint