--- id: cpp-while-loop title: "C++ While Loop" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["while statement", "C++ while 반볡문"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.84 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["cpp", "programming-language", "w3schools", "loops", "while"] raw_sources: ["https://www.w3schools.com/cpp/cpp_while_loop.asp"] applied_in: [] github_commit: "" --- # [[CPP While Loop]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) Just as with C, the same explanation for why `i` is the traditional loop-counter name (short, traditional, stands for "index"/"iterator") is repeated verbatim β€” confirming this naming convention is treated as universal programming culture the tutorial deliberately re-teaches in every language, not something assumed to already be known from a prior language chapter. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`while (condition) { ... }`** β€” repeats the block as long as the condition remains true, checked before each iteration. [S1] - **Mandatory condition-variable update** β€” forgetting to change the loop-controlling variable causes an infinite loop. [S1] - **`i` as a counter convention** β€” short, traditional, stands for "index"/"iterator." [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Basic counting loop: `int i = 0; while (i < 5) { cout << i << "\n"; i++; }`. [S1] - Countdown loop: `int countdown = 3; while (countdown > 0) { cout << countdown << "\n"; countdown--; } cout << "Happy New Year!!\n";`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - ν˜„μž¬κΉŒμ§€ 발견된 λͺ¨μˆœ 사항 μ—†μŒ (No contradictions found in available sources). C 챕터와 λ™μΌν•œ while 루프 문법 및 μΉ΄μš΄ν„° κ΄€λ‘€κ°€ 확인됨. ## πŸ› οΈ 적용 사둀 (Applied in summary) μΉ΄μš΄νŠΈλ‹€μš΄ ν›„ "Happy New Year!!"λ₯Ό 좜λ ₯ν•˜λŠ” μ˜ˆμ œκ°€ C 챕터와 λ™μΌν•˜κ²Œ μ‹€μ „ ν™œμš© μ‚¬λ‘€λ‘œ μ œμ‹œλ¨. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) A basic counting while loop (C++): ```cpp int i = 0; while (i < 5) { cout << i << "\n"; i++; } ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.84 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[C++ Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[CPP Switch]], [[CPP While Loop RealLife]], [[C While Loop]] - **μ°Έμ‘° λ§₯락:** 반볡문 μ„Ήμ…˜ 첫 챕터 β€” while 루프 μ‹€μ „ 예제(While Loop RealLife) μ±•ν„°λ‘œ 이어짐. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” C++ While Loop β€” https://www.w3schools.com/cpp/cpp_while_loop.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "C++ While Loop" page (Astra wiki-curation, P-Reinforce v3.1 format).