w3resource

Kotlin Control Flow: Exercises, Practice, Solution

Kotlin Control Flow Exercises [ 10 exercises with solution ]

[An editor is available at the bottom of the page to write and execute the scripts.  Go to the editor]

1. Write a Kotlin program to check if a given number is positive, negative, or zero.

Click me to see the solution

2. Write a Kotlin program to check if a given number is divisible by 7.

Click me to see the solution

3. Write a Kotlin program to check if a given character is a vowel or a consonant.

Click me to see the solution

4. Write a Kotlin program to print the first 10 natural numbers.

Click me to see the solution

5. Write a Kotlin program to print the Pascal's triangle of a given number of rows.

Click me to see the solution

6. Write a Kotlin program to print the Fibonacci series up to a given number.

Click me to see the solution

7. Write a Kotlin program to calculate the sum of all numbers between two given numbers.

Click me to see the solution

8. Write a Kotlin program to generate the multiplication table of a given number.

Click me to see the solution

9. Write a Kotlin program to count the number of even and odd elements in an array.

Click me to see the solution

10. Write a Kotlin program to find the GCD (Greatest Common Divisor) of two numbers.

Click me to see the solution

More to Come !

* To run the code mouse over on Result panel and click on 'RERUN' button.*

Kotlin Editor:


Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/kotlin-exercises/control-flow/index.php