Q:

Program to Check if An Array Contains a Given Value | Kotlin

0

Program to Check if An Array Contains a Given Value | Kotlin

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

fun main(args: Array<String>) {

    val num = intArrayOf(10, 52, 55, 69, 78)
    val toFind = 78
    var found = false
    for (n in num) {
        if (n == toFind) {
            found = true
            break
        }
    }

    if (found)
        println("$toFind is found.")
    else
        println("$toFind is not found.")
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now