During the semantic analysis phase, this type of error appears. These types of error are detected at compile time.
Most of the compile time errors are scope and declaration error. For example: undeclared or multiple declared identifiers. Type mismatched is another compile time error.
The semantic error can arises using the wrong variable or using wrong operator or doing operation in wrong order.
Some semantic error can be:
Example 1: Use of a non-initialized variable:
In this code, t is undeclared that's why it shows the semantic error.
Example 2: Type incompatibility:
Example 3: Errors in expressions: