Do-While Loop

Do while loop in Dart

The do while loop is similar to the while loop except that the do while loop doesn;t evaluates the condition for the first time when the loop executes. Howerver, the condition is checked after one iterations.In other worda, the loop will be exectued atleast once in a lifetime.

Syntax for for do whileloop

do{
 //statements
}while(expression);

Example

void main(){
  var num = 6;
  do{
    print(n);
    n--;
  } while(n%2==0)

The program code will produce the following output-

6
4
2

code Try Yourself