# Function Definitions

A function definition specifies the name of the function, the types and number of parameters it expects to receive, and its return type. A function definition also includes a function body with the declarations of its local variables, and the statements that determine what the function does.

## Syntax

*`function-definition`*:\
 [*`type-specifier`*](https://glados-2.gitbook.io/clight/reference/declarations-and-types) *`declarator`* *`compound-statement`*

*`declarator:`*\
&#x20;   [*`identifier`*](https://glados-2.gitbook.io/clight/reference/declarations-and-types) *`parameter-list`*

The parameter list in a definition uses this syntax:

*`parameter-list:`*\
&#x20;   **(** *`parameter-declaration-list`* opt **)**

*`parameter-declaration-list`*:\
&#x20;   *`parameter-declaration`*\
&#x20;   *`parameter-declaration`* **,** *`parameter-declaration-list`*

*`parameter-declaration`*:\
&#x20;   [*`type-specifier`*](https://glados-2.gitbook.io/clight/reference/declarations-and-types) [*`identifier`*](https://glados-2.gitbook.io/clight/reference/declarations-and-types)

The syntax for the function body is:

*`compound-statement`*:\
 **`{`** *`statement-list`*&#x6F;pt **`}`**

*`statement-list:`*\
&#x20;   [*`statement`*](https://glados-2.gitbook.io/clight/reference/statements)\
&#x20;   [*`statement`*](https://glados-2.gitbook.io/clight/reference/statements) *`statement-list`*

## Example

```c
int add(int a, int b)
{
    return a + b;
}
```

This simple example defines the `add` function to have the `int` return type. The function takes two parameters of type `int`, called `a` and `b`. In the `body` of the function, it will return the addition of both variables.
