21. Calculate the sum of even numbers in a range

Required Input:

Range: 1 to 10

Expected Output:

The sum of even numbers is: 30

Code In Kotlin

fun main() { val start = 1 val end = 10 // Add your code here to calculate the sum of even numbers }

Run Code?

Click Run Button to view compiled output

22. Find the average of a list of numbers

Required Input:

[10, 20, 30, 40, 50]

Expected Output:

The average is: 30

Code In Kotlin

fun main() { val numbers = listOf(10, 20, 30, 40, 50) // Add your code here to calculate the average }

Run Code?

Click Run Button to view compiled output

23. Print the Fibonacci series up to a given number

Required Input:

5 terms

Expected Output:

0, 1, 1, 2, 3

Code In Kotlin

fun main() { val terms = 5 // Add your code here to print the Fibonacci series }

Run Code?

Click Run Button to view compiled output

24. Convert a temperature from Celsius to Fahrenheit

Required Input:

25°C

Expected Output:

25°C is equal to 77°F

Code In Kotlin

fun main() { val celsius = 25 // Add your code here to calculate Fahrenheit }

Run Code?

Click Run Button to view compiled output

25. Find the length of a string

Required Input:

"Hello, Kotlin!"

Expected Output:

The length of the string is: 14

Code In Kotlin

fun main() { val input = "Hello, Kotlin!" // Add your code here to calculate the length }

Run Code?

Click Run Button to view compiled output

26. Concatenate two strings

Required Input:

"Hello" and "World"

Expected Output:

Concatenated string: HelloWorld

Code In Kotlin

fun main() { val str1 = "Hello" val str2 = "World" // Add your code here to concatenate the strings }

Run Code?

Click Run Button to view compiled output

27. Check if two strings are anagrams

Required Input:

"listen" and "silent"

Expected Output:

listen and silent are anagrams

Code In Kotlin

fun main() { val str1 = "listen" val str2 = "silent" // Add your code here to check if the strings are anagrams }

Run Code?

Click Run Button to view compiled output

28. Find the number of digits in an integer

Required Input:

12345

Expected Output:

The number of digits is: 5

Code In Kotlin

fun main() { val number = 12345 // Add your code here to count the digits }

Run Code?

Click Run Button to view compiled output

29. Count the occurrences of a character in a string

Required Input:

"hello world" and 'l'

Expected Output:

The character 'l' occurs 3 times

Code In Kotlin

fun main() { val input = "hello world" val charToCount = 'l' // Add your code here to count the occurrences of the character }

Run Code?

Click Run Button to view compiled output

30. Print all prime numbers in a given range

Required Input:

Range 1 to 10

Expected Output:

Prime numbers: 2, 3, 5, 7

Code In Kotlin

fun main() { val start = 1 val end = 10 // Add your code here to print all prime numbers in the range }

Run Code?

Click Run Button to view compiled output

ad vertical

3 of 3