Phase III
Logic and Flow
Making a program compute, decide, and repeat.
Operators compute values, branches select work, and loops repeat it. This phase traces the exact evaluation rules behind each one. It covers division toward zero, signed remainder, compound assignment, short-circuit order, fixed-width shifts, boolean branch conditions, switch statements and expressions, loop invariants, and off-by-one boundaries.
When you finish this phase you can
- Predict integer division and remainder, including negative operands, from the truncation rule and identity
- Explain the implicit cast and single left-side evaluation in compound assignment
- Predict overflow, shift-distance masking, sign extension and zero filling
- Write boolean branches with explicit braces and ordered conditions
- Distinguish a switch statement from a switch expression and use yield in a block arm
- Trace for, while and do-while execution and state an invariant and stopping condition
- 3.1OperatorsCalculate values, compare them, short-circuit boolean expressions, and manipulate fixed-width bit patterns.Bitwise operatorsShort circuit evaluation
- 3.2ConditionalsBoolean branches, braces, ordered tests, and switch statements and expressions without hidden fallthrough.switch
- 3.3Loops and Jump StatementsChoose a loop from its condition, trace its execution order, and prove that each pass makes progress toward stopping.Loops