No, this is not a rule, and sometimes it is even difficult/impossible to achieve. The code that has one entry and one exit point is easier to understand and debug though. Compare this:
int foo()
{
if(something)
return 0;
//100 lines of code
if(something)
return 11;
//100 lines of code
if(something)
return -1;
//100 lines of code
return 0;
}
and this:
int foo()
{
int errorCode = 0;
if(something)
errorCode = 1;
//100 lines of code
if(something)
errorCode = 11;
//100 lines of code
if(something)
errorCode = -1;
//100 lines of code
return errorCode;
}
Now we have just one exit point, and (taking into account the variable name too) it's much easier to understand what the function does. You can also place a breakpoint onto the last return and know that this is the point where function ends, and that you will definitely hit it.