[prev] 55 [next]

Functions (cont)

When a function is called:

  1. the arguments in the calling function are evaluated
  2. C uses "call-by-value" parameter passing …
    • the function works only on its own local copies of the parameters, not the ones in the calling function
  3. function code is executed, until a return statement is reached

    return expression;
    

    • the returned expression will be evaluated
    • the calling function is free to use the returned value, or to ignore it

    The return statement can also be used to terminate a function of return-type void:

    return;