Error:
An Error is a mistake that occurs in a program. The error may be a syntax error,logical error or may b a runtime error.
Syntax Error:
To understand what is a syntax error firstly you have to understand that is a "syntax".
A syntax is a collection of rules to write a program in any programming language is called as syntax.
Now, what is a syntax error ?
A syntax error is a type of error that occurs when we write an instruction which is not according to the rules of programming language or when we write an invalid statement.
Example: missing terminator at the end of any statement in C++ program.
Logical Error:
A logical error is a type of error that occurs due to the mistake of human logic.
Example: Suppose you write a program to find the marks of students how has marks greater than 60. You put less than " < " operator instead of putting greater than " > " operator. This error is called as a logical error.
Runtime Error:
A runtime error is an error that occurs during the execution of a program.
Most common example of runtime error is dividing any number by 0.
What is the most difficult error to find ?
The answer is "Logical Error" because the compiler does not understand it. It only can be solved by rereading the code.
No comments:
Post a Comment