Chapter 3: Program Statements Notes
Control Flow:
- A conditional statement is sometimes called a selection statement.
- Each decision is based on a boolean expression.
- Three types of loop statements: while, do and for statements.
The if statement:
Shorthand “if” statement: a ternary operator, inline if (iif) or ternary if
y = ( x >= 0 ) ? x : -x
which is a convenient way of writing
if ( x >= 0 ) y = x; else y = -x
…..
- Equality operators
- Relational operators
The if-else statement:
Nested if statements:
Boolean expressions:
Logical operators:
Truth Table:
Logical AND and OR operators:
Example of truth table for a specific condition: