Types of errors in C language

There might be many other errors,some obvious and other not so obvious.All these errors can be classified under four types,namely,syntax errors,run-time errors,logical errors,and latent errors.

syntax error :
Any violation of rules of the language results in syntax errors.The compiler can detect and isolate such errors.when syntax errors are present,the compilation fails and is terminated after listing the errors and line numbers in the source program,where the errors have occurred. Remember,in some cases,the line number may not  exactly indicate the place of the error.In other cases,one syntax error may result in a long list of errors.Correction of one or two errors at the beginning of the program may eliminate the entire list.

Run-time errors:Errors such as a mismatch of data types or referencing an out-of-range array element go undetected by the compiler.A program with these mistakes will run,but produce erroneous results and therefore the name run-time errors.Isolating a run-time error is usually a difficult task.
Logical errors:As the name implies,these errors are related to the logic of the program execution.Such actions as taking a wrong path,failure to consider a particular condition,and incorrect order of evaluation of statements belong to this category.Logical  errors do not show uo as compiler-generated error messages.Rather,they cause incorrect translation of the algorithm into the program and a lack of clarity of hierarchy of operators.
consider the  following statement
if(x==y)
printf("they are equal \n");
when x and y are float types values,they rarely become equal,due to truncation errors.The printf call may not be executed at all.A test like while(x!=y)might create an infinite loop.

Latent errors:It is a  'hidden'error that shows up only when a particular set of data is used. For example,consider the following statement:
ratio=(x+y)/(p-q);
An error occurs only when p and q are equal. An error of this kind can be detected only by using all possible combinations of test data.

No comments:

Post a Comment

Analysis of Discrete-time Linear-Invariant Systems

we shall demonstrate that such systems are characterized in the time domain simply by their response to a unit sample sequence.we shall als...