Add Two Integers in Kotlin

thumbnail

In this tutorial, you will learn how to add two integers that is stored in two variables. We will give the name of two variables using first and second. Then, first and second are added using the + operator, and its result is stored in another variable sum. After the addition process, the final sum is displayed using println() function.

Example: Add two integers in Kotlin

fun main(args: Array<String>) {
    val first: Int = 100
    val second: Int = 200
    val sum = first + second
    println("The sum is: $sum")
}

The output will be:

The sum is: 300

Read More:

Back To Top