retagged by
3,806 views

2 Answers

4 votes
4 votes

Lexical error: Error while identifying lexemes. Like inz a; instead of int a;.
Syntax error: Error in the syntax of some construct. Like printf 30; instead of printf("30");
Semantic error: Error in the meaning of the statement. Like, you have evaluated area of triangle as 2L*B. They might not be detected by compilers.

edited by
1 votes
1 votes
Lexical errors are those illegal string, unmatched symbols, length of the boundaries are exceeding.

syntax errors are those missing operand, missing left parenthesis, missing right parenthesis etc.

semantic errors are those type checking does not matches, scope of the functions does not found and type conversion is not happend like this.

But when comparing the three phases with each other the most errors occured in syntax phase.

Related questions

12 votes
12 votes
5 answers
1
Shubhanshu asked Jan 31, 2018
7,151 views
int main() { int 1a, b; Printf("\nGate 2018"); Printf("%d",x); }How many types of error are there in this code?
1 votes
1 votes
1 answer
2
Mrityudoot asked Nov 12, 2023
238 views
How to differentiate between Lexical, semantic and syntax error from a given code snippet.Why is this lexical error and not syntax error? $ y = 0x5i; $