Programming Errors in C
Programming Errors in C
Errors are the problems or faults that occur in the program, which make
the program's behavior abnormal. Programming errors are also known
as bugs or defects, and the process of removing these bugs is known as
debugging.
These errors are detected either during the �me of compila�on or
execu�on.
These errors mainly occur due to mistakes while typing or do not follow
the syntax of the specified programming language. These errors can be
easily debugged.
For example:
Output
In the above output, we observe that the code throws the error that 'a' is undeclared. This
error is nothing but the syntax error only.
Run-time error
Some�mes the errors exist during the execu�on �me even a�er the
successful compila�on known as run-�me errors. When the program is
running, and it is not able to perform the opera�on is the main cause of
the run-�me error. The division by zero is a common example of the run-
�me error. These errors are very difficult to find, as the compiler does not
point to these errors.
Output
Linker error
This can happen either due to the wrong func�on prototyping or the
usage of the wrong header file. For example, the main.c file contains
the sub() func�on whose declara�on and defini�on are done in some
other file such as func. c. During the compila�on, the compiler finds the
sub() func�on in func.c file, so it generates two object files, i.e., main. o
and func. o. At the execu�on �me, if the defini�on of sub() func�on is
not found in the func�on.o file, then the linker error will be thrown. The
most common linker error that occurs is that we use Main() instead of
main().
Output
Logical error
Output
Semantic error
Seman�c errors are the errors that occur when the statements are not
understandable by the compiler.
In the above code, we use the statement a+b =c, which is incorrect as
we cannot use the two operands on the le�-side.
Output
Ahmed Mostafa