Types Of Errors Which Can Occur In C Program

Different types of errors can occur while writing a C program. These errors include the syntax errors, logical errors and run-time errors. These types of errors should be remove from the C program for this purpose i also advise you :-
  • Syntax Errors
A collection of rules for writing a program in a programming language is known as syntax. All statements in C language is written according to these rules. Syntax error is a type of error that occurs when invalid statement is written in the program. A compiler can detect these errors and show message. It can not compiled successfully.
A misspelled , semicolon is not written are Syntax errors.
"forr" instead of "for" is example of this type of error.
  • Logical Errors
A type of error which occurs due to the poor logic of the programmer. A statement with logical errors may produce unexpected and wrong result in the program.
Using condition "x>5" instead of "x<5" is example of Logical Error.
This is most difficult to find because compiler can not detect these types of errors. It also takes alot of time. The programmer must review whole the program then he can identify the error.
  • Run-Time Errors
A type of error that occurs during the execution of the program is known as Run-Time Error. It occurs when a statement directs the computer to execute an illegal operation like a number dividing by zero.

These types of errors occur during the execution. The user may ask the program to open a file that does not exist.

Most Difficult Type Error

Logical error because :-
  1. It cannot detected by the compiler.
  2. It does not crash the program.
  3. The user need to review the whole program.
  4. It may take a lot of time for detecting logical errors.

Note :- You must write the program with full attention. Beginners will make more mistakes but after sometime you will be expert and there will be no mistake. Do mistakes and learn from it.

No comments:

Post a Comment