Kotlin Program to add two numbers
In this program, You will learn how to add two numbers in Kotlin.
20 = 10 + 10
35 = 15 + 20
Example: How to add two numbers in Kotlin.
import java.util.Scanner
fun main(args: Array<String>) {
var a: Int
var b: Int
var sum: Int
var sc = Scanner(System.`in`)
print("Enter two numbers:")
a = sc.nextInt()
b = sc.nextInt()
sum = a + b
println("Sum is:$sum")
}
Output:
Enter two numbers:10 20
Sum is:30