+ 4
What is Semantic error?
Explain with example...
3 Answers
+ 4
TheĀ semantic error means If there is a semantic error in your program, it will run successfully in the sense that the computer will not generate any error messages. However, your program will not do the right thing. It will do something else. Specifically, it will do what you told it to do.
The problem is that the program you wrote is not the program you wanted to write. The meaning of the program (its semantics) is wrong. Identifying semantic errors can be tricky because it requires you to work backward by looking at the output of the program and trying to figure out what it is doing.
example:
Forgetting to divide by 100 when printing a percentage amount
+ 2
Semantic error just means "logic error", where you literally write correct code, but the logic behind it makes it do something that you didn't think about, rather than what you wanted.. For example, writing n3=n1*n2 when really you wanted to divide -- the compiler has no way to tell that you intended to divide instead of multiplying; you told it to multiply, so it does.
0
error in your brain, not affected on syntax