if-else Statement & Nested if-else statements

The if…else construct evaluates a condition before a block of code is executed.

Following is the syntax.

if(boolean_expression){ 
   // statement(s) will execute if the boolean expression is true. 
}

If the Boolean expression evaluates to be true, then the block of code inside the if statement will be executed. If Boolean expression evaluates to be false, then the first set of code after the end of the if statement (after the closing curly brace) will be executed.

The following illustration shows the flowchart of the if statement.

void main() {
  int a = 100;
  if (a < 20) {
    if (a == 100) {
      print("a is equal");
    }
  } else {
    print("a is not equal");
  }
}