# Conditionnal Statements

## If

Run code if a condition is [**True**](https://glados-4.gitbook.io/c/data-types#boolean-type). Otherwise it skip the expression and run the rest of the [**function**](https://glados-4.gitbook.io/c/functions).

Nested if are possible to check different conditions if only when other conditions are evaluated to **True.**

### Synopsis

```
(if (<condition>) {
    <expression-true>
)
```

The condition must be a [**boolean**](https://glados-4.gitbook.io/c/data-types#boolean-type) variable or expression, the expression will be run [**if**](#if) the condition is [**True**](https://glados-4.gitbook.io/c/data-types#boolean-type)**.**

### Example:

```
(func (doc (int c))
{
    (if (2 == c) {
        (c = 1);
    })
    (c);
})
(test 2)
```

In this example, the code in the [**if**](#if) statement will be called only if `c` is [**equal to**](https://glados-4.gitbook.io/c/operators#undefined-5) the value 2.

Here is an example of nested **if's**:

```
(func (doc (int c) (int v))
{
    (if (2 == c) {
        (if ((v + c) == 42) {
            (c = 1);
        })
    })
    (c);
})
(test 2)
```

We check two things:

* C is [**equal to**](https://glados-4.gitbook.io/c/operators#undefined-5) 2
* The sum of c and v is [**equal to**](https://glados-4.gitbook.io/c/operators#undefined-5) 42

So we can add nested [**if**](#if) depending of our needed.
