> For the complete documentation index, see [llms.txt](https://acezxn.gitbook.io/vex-ji-qi-ren-cheng-shi-jiao-xue/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://acezxn.gitbook.io/vex-ji-qi-ren-cheng-shi-jiao-xue/ji-chu-jiao-xue/luo-ji-kong-zhi/if-else.md).

# If else

If 是一個判別邏輯的程式，可以讓程式在某些情況下執行。

<img src="/files/b0JRsp3CoE3xddll8KOe" alt="" class="gitbook-drawing">

## Example:

```cpp
bool no_idea;

if (no_idea) {
    keep_learning();
} else {
    make_design();
}
```

if else statement 也可以是更複雜的結構：

```cpp
int days_before_vacation;

if (days_before_vacation > 5) {
    printf("days_before_vacation is more than 5\n");
}
else if (days_before_vacation > 3) {
    printf("days_before_vacation is between 4 and 5\n");
}
else if (days_before_vacation > 1) {
    printf("days_before_vacation is between 2 and 3\n");
}
else {
    printf("days_before_vacation is 1 or less\n");
}
```
