---
id: c-conditions-short-hand
title: "C Short Hand If Else"
category: "Programming_Language"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["ternary operator", "condition ? true : false", "C 삼항 연산자"]
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", "ternary-operator"]
raw_sources: ["https://www.w3schools.com/c/c_conditions_short_hand.php"]
applied_in: []
github_commit: ""
---

# [[C Short Hand If Else]]

## 🎯 한 줄 통찰 (One-line insight)
The ternary operator is explicitly named for its OPERAND COUNT — "because it uses three operands" (condition, true-expression, false-expression) — not because of any special syntax category, meaning it's simply the only operator in C that takes three arguments rather than the usual one or two, which is why it stands out enough to warrant special naming. [S1]

## 🧠 핵심 개념 (Core concepts)
- **Ternary operator (`?:`)** — a shorthand if/else that RETURNS a value rather than branching execution; syntax: `variable = (condition) ? expressionTrue : expressionFalse;`. [S1]
- **Three operands** — condition, true-branch expression, false-branch expression — the origin of the name "ternary." [S1]
- **Equivalent to a simple if/else** — best suited for replacing straightforward two-branch if/else statements, not complex multi-branch logic. [S1]
- **Stylistic choice** — the source explicitly states it's "completely up to you" whether to use traditional if/else or the ternary form. [S1]

## 📖 세부 내용 (Details)
- Traditional if/else form: `int time = 20; if (time < 18) { printf("Good day."); } else { printf("Good evening."); }`. [S1]
- Equivalent one-line ternary form: `int time = 20; (time < 18) ? printf("Good day.") : printf("Good evening.");`. [S1]

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

## 🛠️ 적용 사례 (Applied in summary)
현재 발견된 실제 적용 사례가 없습니다 — 시간에 따른 인사말 출력을 한 줄로 압축하는 예제가 삼항 연산자의 대표 실전 활용이다. [S1]

## 💻 코드 패턴 (Code patterns)
A simple if/else compressed into one line using the ternary operator (C):
```c
int time = 20;
(time < 18) ? printf("Good day.") : printf("Good evening.");
```

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

## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[C Tutorial]]
- **관련 개념:** [[C Conditions ElseIf]], [[C Conditions Logical]]
- **참조 맥락:** 삼항 연산자 — 조건문 내 논리 연산자(Conditions Logical) 챕터로 이어짐.

## 📚 출처 (Sources)
- [S1] W3Schools — C Short Hand If Else — https://www.w3schools.com/c/c_conditions_short_hand.php

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