docs(10_Wiki): Dev 폴더 누락분 반영 — Topic_Programming으로 통합
이전 재구성 작업에서 Dev/ 폴더가 누락되었던 것을 반영. - Dev/Topic_Programming(중첩 폴더, 78개)은 Dev 자체 최상위 폴더들 (Architecture/Conventions/Engineering_Intelligence 등)과 완전 중복이라 제거. - Dev 최상위 엔지니어링 지식 폴더(Architecture/Conventions/Engineering_Intelligence/ Failure_Library/Generalized_Principles/Language/Pattern_Catalog/Platform_Guides/ Subsystems, 77개)는 이미 Topic_Programming/Topic_Programming에 더 최신 버전이 존재해 중복 제거(고유 콘텐츠 1개는 예외 처리하여 이동 보존). - Dev의 W3Schools 언어 튜토리얼 폴더(Topic_C/CPP/CSS/CSharp/HOWTO/HTML/Java/ JavaScript/PHP/Python/SQL/W3CSS, 1201개)는 전부 Topic_Programming 하위로 이동. - 에이전트 운영 상태(.astra/docs)는 그대로 유지, 콘텐츠 폴더만 정리. - Topic_Programming 최종 문서 수: 2784 → 3985.
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: c-conditions-nested
|
||||
title: "C Nested If"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["if inside if", "dependent conditions", "C 중첩 if"]
|
||||
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: ["c", "programming-language", "w3schools", "conditions", "nested-if"]
|
||||
raw_sources: ["https://www.w3schools.com/c/c_conditions_nested.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[C Nested If]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A nested `if` only ever gets EVALUATED at all if the outer condition is true — the voting-and-citizenship example never even checks `isCitizen` if `age >= 18` is false, meaning nesting isn't just visual grouping of related checks, it's a genuine short-circuit optimization where the inner condition's cost (and its own true/false branches) is entirely skipped when the outer gate fails. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Nested if** — placing an `if` statement inside another `if`'s block, so the inner condition is only checked when the outer condition is already true. [S1]
|
||||
- **Dependent condition modeling** — naturally expresses "check B only if A holds" logic, like age eligibility gating a citizenship check. [S1]
|
||||
- **Depth caution** — the source explicitly warns against nesting too deeply, as it can hurt readability; nested if is commonly combined with `else`/`else if` for richer decision trees. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic two-level nesting: `int x = 15; int y = 25; if (x > 10) { printf("x is greater than 10\n"); if (y > 20) { printf("y is also greater than 20\n"); } }` — both print since both conditions hold. [S1]
|
||||
- Voting + citizenship real-life example: `int age = 20; bool isCitizen = true; if (age >= 18) { printf("Old enough to vote.\n"); if (isCitizen) { printf("And you are a citizen, so you can vote!\n"); } else { printf("But you must be a citizen to vote.\n"); } } else { printf("Not old enough to vote.\n"); }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **중첩 if의 단축 평가 효과**: 바깥 조건이 거짓이면 안쪽 if의 조건 자체가 아예 평가되지 않는다는 점이 나이/시민권 예제로 확인됨 — 관련 없는 하위 조건을 불필요하게 검사하지 않는 효율성을 제공. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
투표 가능 연령(18세 이상)을 먼저 확인하고, 그 안에서만 시민권 여부를 추가로 확인하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
An inner condition (citizenship) checked only when the outer condition (age) already holds (C):
|
||||
```c
|
||||
int age = 20;
|
||||
bool isCitizen = true;
|
||||
if (age >= 18) {
|
||||
printf("Old enough to vote.\n");
|
||||
if (isCitizen) {
|
||||
printf("And you are a citizen, so you can vote!\n");
|
||||
} else {
|
||||
printf("But you must be a citizen to vote.\n");
|
||||
}
|
||||
} else {
|
||||
printf("Not old enough to vote.\n");
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C Tutorial]]
|
||||
- **관련 개념:** [[C Conditions Logical]], [[C Conditions RealLife]]
|
||||
- **참조 맥락:** 중첩 if — 조건문 실전 예제(Conditions RealLife) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C Nested If — https://www.w3schools.com/c/c_conditions_nested.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C Nested If" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user