# 3. Объявление переменных

{% file src="/files/yLy9d7eTReIrmJMqwI8N" %}
Весь приведённый далее код оформлен с использованием clang-format
{% endfile %}

{% code overflow="wrap" lineNumbers="true" %}

```c
int main(void)
{
    int a, b, c;
    char *myarray;
    float f, d, g;
    double rr;

    // 100500 lines below

    // 1. Какие переменные объявлены на текущий момент?
    // 2. Какие значения они хранят?
    // 3. Для чего каждое из них используется?
}
```

{% endcode %}

<details>

<summary>Вариант реорганизации и исправления кода</summary>

Переменные/объекты должны объявляться как можно ближе к месту их фактического использования.

{% code overflow="wrap" lineNumbers="true" %}

```c
int main(void)
{
    int a, b, c = 0;
    // work with a, b, c

    char *myarray = NULL;
    // work with myarray

    if (CONDITION)
    {
        float f, d, g = 5.2f;
        // work with f, d, g
    }

    double rr = .5;
    // work with rr
}
```

{% endcode %}

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://skkv-itmo.gitbook.io/c-cpp-cookies/best-practices/best-practices/def-vars.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
