Kotlin Arithmetic Operators
Chapter:
Kotlin
Last Updated:
15-11-2017 17:54:01 UTC
Program:
/* ............... START ............... */
fun main(args: Array<String>) {
val val1 = 7.3
val val2 = 3.2
var result: Double
result = val1 + val2
println("val1 + val2 = $result")
result = val1 - val2
println("val1 - val2 = $result")
result = val1 * val2
println("val1 * val2 = $result")
result = val1 / val2
println("val1 / val2 = $result")
result = val1 % val2
println("val1 % val2 = $result")
}
/* ............... END ............... */
Output
val1 + val2 = 10.5
val1 - val2 = 4.1
val1 * val2 = 23.36
val1 / val2 = 2.28125
val1 % val2 = 0.8999999999999995
Notes:
-
Kotlin programming language supports various arithmetic operators for all floating-point and integer numbers. These operators are + (addition), - (subtraction), * (multiplication), / (division), and % (modulo).
- Above program explains about the all arithmetic operations.
- The + operator is also used for the concatenation of String values.
Tags
Arithmetic Operators, Kotlin