> For the complete documentation index, see [llms.txt](https://glados-2.gitbook.io/clight/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://glados-2.gitbook.io/clight/reference/functions/function-definitions.md).

# 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`*](/clight/reference/declarations-and-types.md) *`declarator`* *`compound-statement`*

*`declarator:`*\
&#x20;   [*`identifier`*](/clight/reference/declarations-and-types.md) *`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`*](/clight/reference/declarations-and-types.md) [*`identifier`*](/clight/reference/declarations-and-types.md)

The syntax for the function body is:

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

*`statement-list:`*\
&#x20;   [*`statement`*](/clight/reference/statements.md)\
&#x20;   [*`statement`*](/clight/reference/statements.md) *`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.
