--- id: c-operators-comparison title: "C Comparison Operators" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["== != > <", "boolean 1 or 0", "C 비교 연산자"] 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", "operators", "comparison"] raw_sources: ["https://www.w3schools.com/c/c_operators_comparison.php"] applied_in: [] github_commit: "" --- # [[C Comparison Operators]] ## 🎯 한 줄 통찰 (One-line insight) Unlike languages with a dedicated `bool`/`Boolean` type, C's comparison operators return plain INTEGERS — `1` for true, `0` for false — meaning the result of `x > y` can be printed with `%d` just like any other int, stored in an `int` variable, and used in arithmetic, because C has no separate boolean type at this point in the tutorial; true/false IS just 1/0. [S1] ## 🧠 핵심 개념 (Core concepts) - **Six comparison operators** — `==` (equal), `!=` (not equal), `>` (greater than), `<` (less than), `>=` (greater or equal), `<=` (less or equal). [S1] - **Integer return value** — every comparison returns `1` (true) or `0` (false), printable with `%d`. [S1] - **Practical decision-making use** — comparisons are the mechanism for finding answers and making decisions in a program, foreshadowing the upcoming if/else chapters. [S1] ## 📖 세부 내용 (Details) - Basic greater-than check: `int x = 5; int y = 3; printf("%d", x > y); // returns 1 (true)`. [S1] - Voting age eligibility check: `int age = 18; printf("%d\n", age >= 18); // 1 (true) printf("%d\n", age < 18); // 0 (false)`. [S1] - Password length check: `int passwordLength = 5; printf("%d\n", passwordLength >= 8); // 0 (false), too short`. [S1] ## ⚖️ 모순 및 업데이트 (Contradictions & updates) - **비교 결과는 진짜 정수형**: 별도의 불리언 타입 없이 비교 연산 결과가 그냥 1 또는 0인 정수로 반환된다는 점이 명시되며, 이는 이후 Booleans 챕터에서 더 자세히 다뤄질 예정임이 언급됨. [S1] ## 🛠️ 적용 사례 (Applied in summary) 투표 가능 연령 확인(age >= 18)과 비밀번호 길이 확인(passwordLength >= 8)이 원문에서 직접 실전 활용 사례로 제시됨. [S1] ## 💻 코드 패턴 (Code patterns) Comparison operators returning plain integers (1 or 0), used for real-world eligibility checks (C): ```c int age = 18; printf("%d\n", age >= 18); // 1 (true), old enough to vote printf("%d\n", age < 18); // 0 (false) ``` ## ✅ 검증 상태 및 신뢰도 - **상태:** draft - **검증 단계:** conceptual - **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body) - **신뢰 점수:** 0.85 - **중복 검사 결과:** 신규 생성 (New discovery) ## 🔗 지식 그래프 (Knowledge Graph) - **상위/루트:** [[C Tutorial]] - **관련 개념:** [[C Operators Assignment]], [[C Operators Logical]], [[C Booleans]] - **참조 맥락:** 비교 연산자 — 논리 연산자(Operators Logical) 챕터로 이어짐, 불리언(Booleans) 챕터와 직접 연결. ## 📚 출처 (Sources) - [S1] W3Schools — C Comparison Operators — https://www.w3schools.com/c/c_operators_comparison.php ## 📝 변경 이력 (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "C Comparison Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).