Chapter 5 - Decisions The if statement has two parts: 1. a condition 2. a body If the condition is true the statement in the body is executed. Syntax 5.1 - The if Statement ----------------------------- if (condition) statement; // statement is executed if condition is true if (condition) statement1; // statement1 is executed if condition is true else statement2; // statement2 is executed if condition is false if (condition) statement1; // statement1 is executed if condition is true else if (condition2) statement2; // statement2 is executed if condition2 is true else if (condition3) statement3; // statement3 is executed if condition3 is true else statement4; // statement4 is executed if none of the above conditions are true Purpose: To execute a statement when a condition is true or false Syntax 5.1 - Block Statement ---------------------------- { statement1; statement2; . . . } Purpose: To group several statements together to form a single statement