One error in jmd's code. "Greater than" means that the loop condition, and that of the second if, must be <=, not <.

As for the lack of else, it works like this:
Code:
if( condition ) {
} else {
}
is semantically equivalent to
Code:
if( condition ) {
}
if( inverse condition ) {
}
The logical NOT operator is !.

Note that it's not a good idea to write real code this way. Unless the compiler can guess the parallel between condition and inverse condition (and why should it, when no proper programmer writes such code?) the latter will test the condition twice and thus be less efficient.