Explanation : An example will help you understand. Let a be 6 and b be 10. There are 5 numbers between 6 to 10 (both inclusive). This is b-a+ 1 (10 - 6 + 1). rand( ) % (b - a + 1) returns an integer from 0 to (b - a). To make it a to b, add a, giving rand() % (b-a+ 1) + a.
Explanation : If the function is small, it is not going to significantly increase the code size. If it is made inline, there is no function call overhead. How much you gain is proportional to the frequency of call.
Explanation : If the formal parameters are declared constants, the compiler will not allow any changes to be made. So the question of inadvertently corrupting the caller's data, does not arise at all.