Beginner
Compilers & Programming Language Theory
Q40 / 100
What is the difference between syntax and semantics in a programming language?
Correct! Well done.
Incorrect.
The correct answer is A) Syntax is the set of rules defining how valid programs are written (grammar/structure); semantics defines what those programs mean (their behavior or effect)
A
Correct Answer
Syntax is the set of rules defining how valid programs are written (grammar/structure); semantics defines what those programs mean (their behavior or effect)
Explanation
A program can be syntactically valid (well-formed according to the grammar) yet semantically wrong (e.g., adding a string to a boolean). Compilers check syntax via parsing and semantics via type checking and other static analyses.
Progress
40/100