Control Flow
if/else Statements
Master conditional statements, logical operators, and control flow patterns.
Comparison Operators
- a < b : Less than
- a > b : Greater than
- a == b : Equal to
- a != b : Not equal to
Ternary Operator
variable = (condition) ? true : false;
Switch Statement
Switch is a control structure that chooses one code path based on an integer-like value. When cases are dense numbers (1,2,3...), the compiler builds a jump table for instant O(1) lookup.
switch (age) {
case 0 ... 4: // GCC extension
cout << "Free";
break;
default:
cout << "Paid";
}Range syntax (0 ... 4) is a GCC extension.