> For the complete documentation index, see [llms.txt](https://docs.yavuzlar.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yavuzlar.org/egitim/c-plus-plus/2.0-fonksiyonlar/1.14-for-dongusu.md).

# 1.14 For Döngüsü

C++ dilinde **for** döngüsü, belirli bir sayıda tekrar yapmayı kolaylaştırır. Genellikle döngü sayısını bilmemiz gerektiğinde kullanılır.

**Temel Yapı**

**for** döngüsünün temel yapısı şu şekildedir:

```cpp
for (başlangıç; koşul; artırma) {
    // Çalıştırılacak kod bloğu
}
```

**Örnek: Basit Sayma**

Aşağıdaki örnekte, 1'den 5'e kadar olan sayılar yazdırılmaktadır:

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

int main() {
    for (int i = 1; i <= 5; i++) {
        cout << "Sayi: " << i << endl;
    }
    return 0;
}
```

#### C++ İç İçe Döngüler (Nested Loops)

**İç İçe Döngüler**, bir döngü içinde başka bir döngü kullanarak daha karmaşık tekrarlar yapmayı sağlar. İç içe döngüler, çok boyutlu dizilerle çalışırken yaygın olarak kullanılır.

**Örnek: İç İçe For Döngüsü**

Aşağıdaki örnekte, 1'den 3'e kadar olan sayılar için her biri için 1'den 2'ye kadar olan sayılar yazdırılmaktadır:

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

int main() {
    for (int i = 1; i <= 3; i++) {
        for (int j = 1; j <= 2; j++) {
            cout << "i: " << i << ", j: " << j << endl;
        }
    }
    return 0;
}
```

#### C++ Foreach Döngüsü

C++ dilinde **foreach** döngüsü, özellikle diziler veya koleksiyonlar üzerinde yineleme yapmak için kullanılır. Ancak C++'da doğrudan bir `foreach` anahtar kelimesi yoktur. Bunun yerine, **range-based for loop** kullanarak benzer bir işlevsellik elde edebiliriz.

**Temel Yapı**

```cpp
for (veri_türü eleman : dizi) {
    // Çalıştırılacak kod bloğu
}
```

**Örnek: Range-based For Döngüsü**

Aşağıdaki örnekte, bir dizinin elemanlarını yazdırmak için range-based for döngüsü kullanılmaktadır:

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

int main() {
    int dizi[] = {1, 2, 3, 4, 5};

    for (int eleman : dizi) {
        cout << "Eleman: " << eleman << endl;
    }
    return 0;
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.yavuzlar.org/egitim/c-plus-plus/2.0-fonksiyonlar/1.14-for-dongusu.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
