About Me

Hello there! Before talking about qualifications and professional abilities, I would like to introduce myself. I am a Yuvraj Basnet and professional software developer and have been working in this field for 3 long years. I have finished my graduation from The University of Delhi on Computer Science Engineering I considered myself a reasonably experienced programmer with a particular interest in the human side of software development, computers are fascinating machine, but they're mostly reflection of the people using them. In the art of software development, studying code isn't enough; you have to study the people behind the software, too.

Error and Types of Errors in C

Error and Types of Errors in C

Error and Types of Error in C

The coder should know the fact that there is very less chances that a program will executes perfectly in the first time. It doesn’t matter how nicely the coding or designing is done and how much care is taken while coding. no one can say that the program would 100% errors or bug free. So the coders has to make efforts to detect and correct any kind of errors that are present in the programs. But before finding and removing errors it is much more necessary that the coders should know about the types of errors in programming. so in this tutorial we will discuss about the errors and types of errors in programming that must be taken care while coding your program.

Definition of error:
Error is an abnormal condition which is performed by the programmer whenever it occurs execution of the program is stopped. Programming errors often remain hidden until the codes is compiled or executed. Some of the errors stopped the program from getting compiled or executed. because of this errors should be removed before compiling and executing.

Types of Errors in Programming are classified into five categories

1. Compile Time Error or Syntax Error:

If any error is generated at the time of compilation is known as compile time error, in general these are the errors which occurs while break the rules and regulation of programming languages and these errors are easily detected by the compiler. If compile time errors are detected by the compiler in the program then the compilation of the program fails and is discontinue after showing the list of errors with the line number where the errors have occurred. In some cases the line number may not exactly indicate the correct place of the errors.


Compile Time Error

Here, program is terminated and showing error because after the 
printf() semicolon is missing (;)

error: expected ';' before '}' token

2. Run-time Errors:

Run-time errors are those errors that occur during program execution after the successful compilation are called run-time errors. In general, These error are occurs when the logic of the program is wrong. most common run time error is insufficient memory for dynamic memory allocation, dividing by zero error also known as Division error. These are not catch by compiler at the compile time of the program. A program which contain these kinds of errors will run but produce incorrect results or may cause discontinue of program. these types of errors are difficult to find as the compiler does not point the line at which the error occurs.


Run-Time Error

warning: division by zero [div-by-zero]
div = n/0;

3. Logical Errors:

As the name suggest itself, these error are those which are related to the logic of the program. Those types of errors which provide incorrect output but appears to be error free are called logical errors. and these errors are also not detected by the compiler similar to the run-time errors and produced incorrect outputs. logical error occurs because the erroneous translation of algorithm into the program, lack of clarity of hierarchy of the operators. 


Logical Error

4. Semantic errors:

Semantic error occurs when the line of codes which written in the program are not meaningful to the compiler or we can say that when a line of codes is syntactically valid but does not do what the programmer wants.


Semantic Error

error: lvalue required as left operand of assignment
num1 + num2 = num3; //semantic error

5. Linker Errors:

Linker error occurs when after compilation we link the several object files with main’s object using Control (ctrl+F9) key(RUN). These are errors detected when the executable of the program cannot be achieved. This may be due to wrong function prototyping, erroneous header files. One of the most common linker error is writing Main() instead of main() [capital letter M instead of m). 


Linker Error

(.text+0x20): undefined reference to `main'


Post a Comment