# 1.11 If Else

C++ dilinde **if** ve **else** yapıları, koşullu ifadeleri kontrol etmek için kullanılır. Programın belirli bir koşul doğru olduğunda farklı bir yol izlemesini sağlar.

**Temel Yapı**

**if** ifadesi, belirli bir koşulu kontrol eder ve koşul doğruysa (true) belirli bir kod bloğunu çalıştırır. Eğer koşul yanlışsa (false) **else** ifadesi kullanılarak alternatif bir kod bloğu çalıştırılabilir.

```cpp
#include <iostream>
using namespace std;

int main() {
    int sayi = 10;

    if (sayi > 5) {
        cout << "Sayı 5'ten büyüktür." << endl;
    } else {
        cout << "Sayı 5'ten küçüktür veya eşittir." << endl;
    }

    return 0;
}
```

**Çoklu Koşullar**

Birden fazla koşul kontrol etmek için **else if** ifadesi kullanılabilir. Bu, birden fazla koşulu kontrol etme esnekliği sağlar.

```cpp
#include <iostream>
using namespace std;

int main() {
    int not = 85;

    if (not >= 90) {
        cout << "Not: A" << endl;
    } else if (not >= 80) {
        cout << "Not: B" << endl;
    } else if (not >= 70) {
        cout << "Not: C" << endl;
    } else {
        cout << "Not: D" << endl;
    }

    return 0;
}
```

**Kısa If İfadesi**

C++ dilinde koşullu ifadeleri daha kısa bir şekilde yazmak için **ternary operatörü** (`? :`) de kullanılabilir. Bu operatör, bir koşulu kontrol eder ve uygun sonucu döndürür.

```cpp
#include <iostream>
using namespace std;

int main() {
    int sayi = 4;
    string sonuc = (sayi % 2 == 0) ? "Çift" : "Tek";
    cout << "Sayı: " << sonuc << endl;

    return 0;
}
```


---

# 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://docs.yavuzlar.org/egitim/c-plus-plus/2.0-fonksiyonlar/1.11-if-else.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.
