Different types of errors in C language occurs


Different types of errors in C language occurs
Errors/bugs are very common while developing a program. If we don't detect them and correct them, they cause a program to produce wrong results. There are three types of errors — syntax, logical, and run-time errors. Let us look at them: 
  1. Syntax errors: These errors occur because of wrongly typed statements, which are not according to the syntax or grammatical rules of the language.
For example, in C, if you don’t place a semi-colon after the statement (as shown below), it results in a syntax error.
printf(“Hello,world”) – error in syntax (semicolon missing)
printf("Hello,world"); - This statement is syntactically correct. 
  1. Logical errors: These errors occur because of logically incorrect instructions in the program. Let us assume that in a 1000 line program, if there should be an instruction, which multiplies two numbers and is wrongly written to perform addition. This logically incorrect instruction may produce wrong results. Detecting such errors are difficult.
  1. Runtime errors: These errors occur during the execution of the programs though the program is free from syntax and logical errors. Some of the most common reasons for these errors are
    1. when you instruct your computer to divide a number by zero.
    2. when you instruct your computer to find logarithm of a negative number.
    3. when you instruct your computer to find the square root of a negative integer.
     4. Linking Error: These errors are occurs due to the linking of header files to the current program.
Unless you run the program, there is no chance of detecting such errors

Followers