A semantic error is a logic error. That is, the code may compile and run, but does not perform as you intended.
Some semantic errors can be picked up by the compiler, often shown as warning, such as:
if (x = 5) // warning: did you mean x == 5?
Others are simply impossible for the compiler to spot:
int x, y, z;
// ...
++z; // add 1 to x
In the above code, we meant to increment x, but incremented z instead. The compiler won't notice the error so this will inevitably lead to a runtime error.
Copyright © 2026 eLLeNow.com All Rights Reserved.