Kotlin Program to find ASCII Value of a Character

Greetings!
We have recently published 100+ articles on android tutorials with kotlin and java. If you need, you may visit Android Tutorial for beginners page. You can also check Kotlin Tutorial for beginners. Also, if you are interested in content writing, you can mail us at tutorialwing@gmail.com.

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"

    println(res)
}

When you run the program, output will be

 ASCII value of d is 100
 
Explanation:

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.

Support Us

If you like Tutorialwing and would like to contribute, you can email an article on any educational topic at tutorialwing@gmail.com. We would love to publish your article. See your article on Tutorialwing and help others with your knowledge. Follow Facebook, LinkedIn, Google+, Twitter, Youtube for latest updates.
Greetings!
We have recently published 100+ articles on android tutorials with kotlin and java. If you need, you may visit Android Tutorial for beginners page. You can also check Kotlin Tutorial for beginners