do-while loop in Kotlin

do-while loop executes statements at least once irrespective of the condition. In other words, this loop executes the statements present in its body before evaluating the condition.

Syntax of do-while loop

do{
   //code to be executed when condition is true
}while(condition)

Flowchart of do-while loop

Flowchart of do-while loop

Example of do-while loop

fun main(args: Array<String>){
   var i = 1
   do{
      println(3*i)
      i++
   }while(i<=10)
}

Output

3
6
9
12
15
18
21
24
27
30