Types Of Errors In Programming
Hello Programmer,
Today we discuss Type Of Errors In Programming. As a programmer, you know that whenever you write code there is at least one error in your program and these errors terminate your program unexpectedly or create a problem.
Every programmer thinks whenever he or she write program his or her program be error-free. Because when there is an error in your program your program will not be work properly.
Every programmer thinks whenever he or she write program his or her program be error-free. Because when there is an error in your program your program will not be work properly.
Now firstly tell you what is an error in the program...
Errors are the mistake or fault in the program that cause our program to behave unexpectedly and it is no doubt that the well versed and experienced programmers also make mistakes.
Programming error is generally known as Bugs and the process to remove bugs from the program is called as Debug/Debugging.
Now It's time to discuss Type Of Errors In Programming
1) Lexical Errors: As a Programmer, you know how to declare an identifier but when you declare identifier inappropriate manner that time your compiler give you a lexical error.
A Lexical error is any input that can be rejected by the lexer. This generally results from token recognition failing off the end of the rules you've defined.
A Lexical error is when the input doesn't belong to any of these lists:
keywords: "if", "else", "main"...
Symbols: '=', '+', ';'...
Double symbols: ">=", "<=", "!=", "++"
Example: 9var, error, number before character, not a variable and not a keyword.
A syntax error is an error in the syntax of a sequence of characters or tokens that are intended to be written in compile-time. A program will not compile until all syntax errors are corrected.
It is easy to find syntax error because most of the programming language tells you which syntax you left in your code.
During the syntax analysis phase, this type of error appears. A syntax error is found during the execution of the program.
Some syntax error can be:
- Error in structure
- Missing operators
- Unbalanced parenthesis
Error in structure...
Missing Operators...
Unbalanced parenthesis...
3) Semantic Errors: Semantic error is scope and invalid declaration error. These can arise using the wrong variable or using the wrong operator.
Some semantic error can be...
- Incompatible type of operands
- Undeclared variable
- Not matching of an actual argument with formal argument
Incompatible type of operands...
Undeclared variable...
Not Matching of an actual argument with the formal argument...
4) Logical Error: As a programmer, we all know that programming is totally based on logic. Logic is a way to solve any problem. If you build a wrong logic then it raises a logic error or logical error.
The logical error looks like error-free but it gives an incorrect output.
These errors solely depend on the logical thinking of the programmer and are easy to detect if we follow the line of execution and determine why the program takes that path of execution.
example:
#include<iostream>
using namespace std;
int main()
{
while(1>0)
cout<<"1> 0";
} // Infinite Loop
5) Runtime Error: A Runtime error occurs when a program is in running state this type of error occurs when your program tries to access any file or module but it is not present in a given position.
A program crash is the most noticeable type of runtime error since the program unexpectedly quits while running. Crashes can be caused by memory leaks or other programming errors. A common example includes dividing by zero, referencing the missing file, calling invalid function, or not handling certain input correctly.
6) Compile Time Error: This type of error occurs when a program is being compiled.
These errors occur when we do not obey the syntax or grammar of the programming language. They are discovered by the compiler is a statement it does not recognize as a valid statement.
Most frequent Compile-Time errors are:
- Missing Parenthesis
- Printing the value of a variable without declaring it
- Missing semicolon
Comments :
Post a Comment