![]() ![]() ![]() while keyword is used to specify the condition which is ended by using semicolon. If the condition is true, it will repeat the execution of the loop else stop the execution of the loop. do first execute the block of the code and then check the condition. The syntax of the do-while loop in kotlin is as followsÄo keyword is used to implement the do-while loop in kotlin. while loop first checks the condition and then executes the block of the code, whereas do-while loop, first execute the block of the code then checks the condition. Kotlin do-while loop is the same as while loop, only one difference is there. The same procedure is performed until the condition becomes false. num++ wi in cream the num by 1, again it checks the condition and prints 2. Inside the loop, the print is used to print the num and increment the num. ![]() As we have to print the number from 1 to 10, we have mentioned the condition num <= 10. First, we have initialized the num variable to 1. Here we have written a program to print the number of 1 to 10. Println("Program to print number from 1 to 10") ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |