Use of "else" for Arduino programs

Each else in a program needs an if. Not all IFs need an else or an else if.

As an example:

If( I am hungry) {

eat;

} else {

do not eat;

}

Now this example has two instruction blocks that could be executed. “eat” if you are hungry or “do not eat” if you are not. The else indicates to the compiler what instruction or instructions will be executed for each clause. In the above I used curly braces to indicate the blocks of code to be executed in each case. If the curly braces are absent, only the next single instruction will be executed.

It is generally considered good form to use curly braces even if you are only executing one line of code. Although this is compilable:

If( I am hungry)

eat;

else

do not eat;

Someone needs to give you a book on C/C++ for your birthday!