Checking if a number is within a certain range

Report a typo

Let's imagine you have a Kotlin program with a number that is checked whether it is within a certain range or not. Your task is to fill the blanks in the code, define the range, and also insert the appropriate relational operator to make this checking operation work correctly. Remember, the range is an interval from start to end, and in Kotlin, it's usually created with the .. operator. Choose the correct operator and range to print out if the number is in the defined range or not.

Fill in the gaps with the relevant elements
fun main() {
    val  = 
    val number = 5

    if (number  range) {
        println("$number is in the range")
    } else {
        println("$number is not in the range")
    }
}
in1..10range
___

Create a free account to access the full topic