Nested if Statement
It is possible to have if within if statement. The if within an if is called nested if. The flowchart illustrates the concept of nested if. Do take note that if can also be place within else statement.
Enter a number between -10 and 10: 6
6 is a positive number
6 is an even number
Here we have if else selection structure within the if statement that tests whether the variable num is an even or odd number. Notice that the nested if will only be checked if the condition of the if statement is true. The braces enclosing the nested if are necessary to make the nested if a part of if (first) statement.
Next: switch Statement