In life, things sometimes do not go according to plan. You may find, for example, that you have budgeted to buy some things for when you go to the store. But when you actually arrive at the store, you see some items that are not on your list are on sale and you buy them! That is an incident where the initial plan was not executed well and did not produce the expected results.
A similar scenario can arise while programming. When you write some code and run it, unexpected situations can occur, which may cause the code not to be executed correctly or not produce the expected results. For example, there could be a problem with syntax, an undefined variable you are trying to use, or even a completely unforeseen scenario. When code does not execute as intended, we say that an error has occurred.
Some errors can be logical errors. These can occur when specifications are not followed. For example, this could be a function that is supposed to return the sum of two numbers but actually...