What are conditional statements in DART

In this article, i will describe about conditional statements in Dart.
  • 1742

The conditional statements

The control flow statements which allow us to control the flow of our program, rather than executing every line of code in order it appears in the program., and in control flow the conditional statements allow us to checks; whether certain condition is met or not. The conditional statements are given below

  • The if-else statements

    In if-else statements, if condition is true; then if part is executed otherwise else.

Example of if-else statements

void main() {

  bool i=true;

  if(i){

    print("True");

  }

  else{

    print("False");

  }

  print("Are you agree with if-else satatements!");
}


Output:

ifelse.png

  • The switch statements

    The switch case statements is good for selecting one branch of execution from a set of mutually exclusive ones. If no case is matched, then default case is executed.

Example of switch statements
 

void main() {

  int i=5;

  switch(i){

    case 1:

      print("One");

      break;

    case 5:

      print("Result is five");

      break;

    default:

      print(" No  case is  match");

  }
}


Output:

 switchdart.png

Ask Your Question 
 
Got a programming related question? You may want to post your question here
 
© 2020 DotNetHeaven. All rights reserved.