What is Semantic error? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

What is Semantic error?

Explain with example...

17th Aug 2018, 11:18 AM
Nitin Gutte
Nitin Gutte - avatar
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
17th Aug 2018, 12:06 PM
Maninder $ingh
Maninder $ingh - avatar
+ 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.
17th Aug 2018, 12:11 PM
Mayur Shedage
Mayur Shedage - avatar
0
error in your brain, not affected on syntax
21st Aug 2018, 11:03 PM
Арсений Чеботарёв
Арсений Чеботарёв - avatar