How does a computer solve a problem?

Here is how you can imagine this better.  Suppose you are an architect who knows how to design a house  and just got a job in Japan and wants to build a house there.  You don't know the Japanese language but you have access to a translator.  So, you write, on a piece of paper, a set of instructions in English and will give that to the translator.  The translator will bring you a copy of your instructions in Japanese the next day.  This would happen if the translator would understand everything that you have said.  If there is something that wouldn't make sense to him/her (syntax error), the translator would halt his/her job and would let you know that there was something that must be fixed before he/she could give you a correct final translation.  The possible errors could be caused by a set of syntactically incorrect instructions or could be due to missing syntax.  If you have no error, then you would have a translation in your hand a bit later.  When you look at the translated instructions set, you don't understand it, after all it is written in a different language. But don't be worried about this, there is someone who can read these instructions and complete the house for you. The next thing you need to do is to find a Japanese architect to build the house.  If you are lucky (for know we assume you are), the translator and the architect may be the same person but you need to get the translation and resubmit it to him/her for execution.  The next thing that should happen is that the Japanese architect will bring all the resources together and will build the house for you.  If all your measurements are correct and all the requests are valid, you will get a good house. Sometimes you may have made a request that is impossible to complete.  An invalid request may not necessary be due to a wrong syntax.  For example, you have asked the builder to build a dog house with height 0.  Although that dimension is a valid dimension on the paper, it is not practical.  So you may have asked the builder to build something that is not possible, in which case he/she will let you know at the time that is executing the instruction set (run-time error). A third type of error that may happen is due to a mistake that you have made when you designed your algorithm or when you were writing the set of instructions.  For example, you may have written "keep the distance between each steps at 1 foot" but you meant to say "keep the distance between each steps at 1/2 foot". In that case, the builder will build have the steps placed based on what he/she sees on the instruction set.  This kind of error is called logic error.  How many of them do you see in your daily life? Doors that get open on the wrong side and steps that are too far apart or too close to each other.

We can compare some of the characters and parts of this story to what we will see in a programming class:

You know how to design a house                                    You know how to write a C++ program - syntax
The set of instructions you write                                       Your C++ program
The Japanese translator                                                    The C++ compiler
The translated version of your program                             The Executable file produced by the compiler
The Japanese architect                                                     The C++ compiler
Resources                                                                        Linker, input data,  ....
The house                                                                        The output from your program

You may find other similarities as well.