previous | start | next

## Array Parameters

- When writing a function with an array parameter, you place an empty`[]` behind the parameter name:

  >     double maximum(double a[], int a_size);

- You need to pass the size of the array into the function, because the function has no other way of querying the size of the array (there is no `size()` member function)
- Unlike all other parameters, array parameters are always passed by reference.

  >     void raise_by_percent(double s[], double s_size, double p)
  >     {
  >        int i;
  >        for (i = 0; i < s_size; i++)
  >           s[i] = s[i] * (1 + p / 100);
  >     }

- Never use an `&` when defining an array parameter.
- Use the `const` keyword whenever a function does not actually modify an array.

  >     double maximum(const double a[], int a_size)

previous | start | next