Find the error

Report a typo

Your friends asked for your help in solving a coding problem. They were trying to create a utility method for swapping two integer numbers, but something went wrong and the method does not work as expected. Use your debugging skills to fix the problem.

Sample Input 1:

29
-16

Sample Output 1:

-16
29
Write a program in Kotlin
import java.util.Scanner

fun swapInts(ints: IntArray): IntArray {
return intArrayOf(ints[1], ints[0])
}

fun main() {
val scanner = Scanner(System.`in`)
while (scanner.hasNextLine()) {
var ints = intArrayOf(
scanner.nextLine().toInt(),
scanner.nextLine().toInt(),
)
swapInts(ints)
println(ints[0])
println(ints[1])
}
}
___

Create a free account to access the full topic