Semantic Errors
When a sentence is syntactically correct but has no meaning, semantic errors occur. This is similar to grammatical errors. If an expression is entered on the left side of the assignment operator, a semantic error may occur.
Example:
C++
// C++ program to demonstrate // a semantic error #include <iostream> using namespace std; int main() { int a = 10, b = 20, c; a + b = c; cout << c; return 0; } |
Output:
C++ Program to Show Types of Errors
In any programming language errors is common. If we miss any syntax like parenthesis or semicolon then we get syntax errors. Apart from this we also get run time errors during the execution of code. In a similar way the errors are classified as below:
- Syntax Errors
- Runtime Errors
- Logical Errors
- Linked Errors
- Semantic Errors