Get last digit

Report a typo

Write a function named getLastDigit that takes one number and returns its last digit.

Use the provided template.

Sample Input 1:

12345

Sample Output 1:

5

Sample Input 2:

-512

Sample Output 2:

2
Write a program in Kotlin
// write your code here

/* Do not change code below */
fun main() {
val a = readLine()!!.toInt()
println(getLastDigit(a))
}
___

Create a free account to access the full topic