2.4 Nested if Statements

0 阅读1分钟

1. Exam Points

  • Nested if statements
  • Nested if-else statements
  • Nested if-else...if statements
  • Note:
    • First check what a question asks.
    • inner if statement is evaluated only if outer if statement is true.
    • Check the outer if statements first, then the inner if statements.
    • Ignore the if or else statements that will not be executed.

2. Knowledge Points

(1) Nested if Statements

  • Nested if statements consist of if, if-else, or if-else-if statements within if, if-else, or if-else-if statements.
    • Example 1: if inside if
      image.png
    • Example 2: if...else inside if
      image.png
    • Example 3: find the maximum among 3 variables. image.png

3. Exercises