Kotlin Program to find ASCII Value of a Character

In this post, we will go through program to find ASCII value of a character in Kotlin programming language.

Source Code to find ASCII value

fun main() {

    val exampleChar = 'd'

    // Get ASCII value of exampleChar
    val asciiValue = exampleChar.toInt()

    val res = "ASCII value of $exampleChar is $asciiValue"


When you run the program, output will be

 ASCII value of d is 100

We have taken character ‘d’ as an example to find it’s ASCII value.
At first, we stored character ‘d’ in variable exampleChar.
Then, we get it’s integer value using kotlin’s built-in function toInt().
Result of this toInt() function is ASCII value of that character.

Thus, we went through a kotlin program to find ASCII value of a character.

Leave a Reply