---
id: c-for-loop
title: "C For Loop"
category: "Programming_Language"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["for statement", "three-expression loop", "C for 반복문"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.85
created_at: 2026-07-04
updated_at: 2026-07-04
review_reason: ""
merge_history: []
tags: ["c", "programming-language", "w3schools", "loops", "for-loop"]
raw_sources: ["https://www.w3schools.com/c/c_for_loop.php"]
applied_in: []
github_commit: ""
---

# [[C For Loop]]

## 🎯 한 줄 통찰 (One-line insight)
The source frames the `for` vs `while` choice as a matter of KNOWING the iteration count in advance — "when you know exactly how many times you want to loop... use the for loop instead of a while loop" — meaning `for` isn't a functionally different tool from `while` (a `for` loop can always be rewritten as a `while`), it's a structural convention that bundles initialization, condition, and increment into one line specifically for the fixed-count use case. [S1]

## 🧠 핵심 개념 (Core concepts)
- **`for (expr1; expr2; expr3) { ... }`** — expr1 runs once before the loop starts; expr2 is the continuation condition checked each iteration; expr3 runs after each iteration's body. [S1]
- **Fixed-count use case** — the recommended tool when the number of iterations is known ahead of time, unlike `while`'s open-ended condition-driven repetition. [S1]
- **Flexible step expressions** — expr3 isn't limited to `++`; any increment/decrement/step size works (`i = i + 2`, `i--`, etc.). [S1]

## 📖 세부 내용 (Details)
- Basic counting: `int i; for (i = 0; i < 5; i++) { printf("%d\n", i); }` — prints 0 to 4. [S1]
- Custom step size for evens: `int i; for (i = 0; i <= 10; i = i + 2) { printf("%d\n", i); }`. [S1]
- Accumulating a sum across iterations: `int sum = 0; int i; for (i = 1; i <= 5; i++) { sum = sum + i; } printf("Sum is %d", sum);`. [S1]
- Countdown via decrement: `int i; for (i = 5; i > 0; i--) { printf("%d\n", i); }`. [S1]

## ⚖️ 모순 및 업데이트 (Contradictions & updates)
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).

## 🛠️ 적용 사례 (Applied in summary)
1부터 5까지의 합을 for 루프로 누적 계산하는 예제(sum = sum + i)가 원문에서 직접 실전 활용 사례로 제시됨. [S1]

## 💻 코드 패턴 (Code patterns)
Accumulating a running total across for-loop iterations (C):
```c
int sum = 0;
int i;
for (i = 1; i <= 5; i++) {
  sum = sum + i;
}
printf("Sum is %d", sum);
```

## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.85
- **중복 검사 결과:** 신규 생성 (New discovery)

## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[C Tutorial]]
- **관련 개념:** [[C Do While Loop]], [[C For Loop Nested]], [[C For Loop RealLife]]
- **참조 맥락:** for 루프 — 중첩 for 루프(For Loop Nested) 챕터로 이어짐.

## 📚 출처 (Sources)
- [S1] W3Schools — C For Loop — https://www.w3schools.com/c/c_for_loop.php

## 📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "C For Loop" page (Astra wiki-curation, P-Reinforce v3.1 format).
