What is conditional statements in DART

In this article, i am going to explain about conditional statements in DART.
  • 2031

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 block is executed otherwise else block is executed .

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:

switchcase.png
 

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