Conditional logic selects which statements execute by evaluating a controlling expression. In C, an if statement runs its secondary block once when the condition is true; an if–else statement selects exactly one of two code paths. section 3.0 section 3.1
Selecting a code path
if (i > 25) { j = i - 25; } else { j = i; } The expression i > 25 controls the choice. The first block executes when it is true; otherwise the else block executes. section 3.1
C conditions follow these rules:
- Zero represents logical false; every nonzero value represents logical true. section 3.1 section 3.4
- Use == and != to test equality and inequality; a numeric value such as i can also serve directly as the condition. section 3.1
Conditional logic also connects to related control constructs. Loops repeatedly test conditions, while switch performs multiple selection on an integer value. The conditional operator, written cond ? A : B, provides expression-level selection and evaluates only the chosen branch. section 3.0 section 4.5




















