We program computers when we have a specific problem that can’t be solved using the programs we already have access to.   First we consider what the solution might be, then we work out the steps necessary to achieve the solution, then we reduce those steps into instructions the compiler can understand.

If the compiler tells us there is an error, it means there is something wrong with the instructions we’ve given it – usually a minor mistake like typing one thing when we mean another, or a misconception about how the programming language works.   However the compiler has no knowledge about the problem we’re trying to solve or our thinking process behind it, so it cannot tell us if our logical reasoning is wrong.   All we can do is run the program, and observe its behaviour.   If it does something unexpected, that means we made a mistake in our reasoning and will have to edit the program and try again.

The program below is designed to make the frog move in a rectangle shape, but there is a compiler error preventing this from happening.  Click the compile button now.  An error message will appear in the box below the program.

As the compiler has no knowledge about the problem we’re trying to solve or how we’re trying to solve it, error messages are not always accurate descriptions of the error, or where in the program the error happened.   In this case though, the message is correct.    

The lines which look similar to...

frogUp();
frogDown();

etc.

...are called statements, and all statements must be followed by a semi-colon.  This is how the language specifies where one statement ends and another begins.

Tasks: