Files
2nd/10_Wiki/Dev/Topic_C/C_For_Loop.md
T
Antigravity Agent 1cfd3bbb56 docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고,
Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
2026-07-05 00:10:59 +09:00

3.3 KiB

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

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):

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)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-07-04: Initial draft synthesized from the W3Schools "C For Loop" page (Astra wiki-curation, P-Reinforce v3.1 format).