Q:

Program to Reverse a Number | Kotlin

0

Program to Reverse a Number | Kotlin

All Answers

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

fun main(args: Array<String>) {
    var num = 5687
    var reversed = 0

    while (num != 0) {
        val digit = num % 10
        reversed = reversed * 10 + digit
        num /= 10
    }

    println("Reversed Number: $reversed")
}

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