The above code may appear to contain a "needless else," but that is only because the example is very small. Functions (or subroutines, whatever your language of choice calls them) should, as a general rule, have only one return statement, if any. This ensures that the function can be traced from beginning to end. I propose that the code be changed thusly:

int IsFive(int a) {
    int result;

    if(a == 5) {
        result = 1;
    } else {
        result = 0;

    return result;

Admittedly, this version is longer, but there is a defined entrance point (which was never really an issue) and a single, defined exit point. This example is fairly trivial, but imagine working on a significantly larger program, written with brevity and minute savings in binary size in mind.

There are exceptions to every rule, however. File opening comes to mind for multiple exit points ( open(IN, $ARGV[0]) or die; ), and StrawberryFrog points out that error codes are much easier to deal with when using multiple return points. On the average, having one exit point makes for code that is easier to follow and debug. This holds especially true for students learning both a new language and how to program in general.

In the world of computing today, this should be a non-issue. Memory and processor cycles are both abundant the majority of the time. Write for clarity and readability unless you're genuinely working with excruciatingly tight memory constraints (e.g., an embedded system) or dealing with a special case. It'll save the next person to work on your code many headaches.