As stated earlier, a function may, but is not required to, return a value of some type.
return
statement returns from a function. It passes control from a function back to the calling location. Program control returns to the location where the function was called when control "falls through" the end of the function (reaches the end brace). If a function is to return a value, it must use a return
statement.
A return statement can include an expression which becomes the return value of the function. The expression must be of the same type as the functions' declared return value.
Function sqr
in the Program Listing 2-3 on page 2-46 (Lines 19 through 21) uses the return
statement to return the square of the number that was passed to it.
sqr (n: int): int { return (n*n); }