previous | start | next

## Writing Functions (Syntax 5.1 : Function Definition)

- To create a function, we must supply its name, return type, and a list of parameters and their names.

  >     double future_value(double p)

- For the duration of the function, the parameter is stored in a parameter variable (in this example, `p`).
- The body of the function is delimited by braces (just like `main()`):

  >     double future_value(double p)
  >     {
  >        . . .
  >     }

- Code is included to perform the computation. The result is returned to the caller function.

  >     double future_value(double p)
  >     {
  >        double b = 1000 * pow(1 + p / 100, 10);
  >        return b;
  >     }

previous | start | next