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

Similar Programs Chapter Last Updated
Kotlin Continue Kotlin 02-03-2018
Kotlin Break Statement Kotlin 27-01-2018
Kotlin For Loop Kotlin 30-11-2017
Kotlin Do While Loop Kotlin 19-11-2017
Kotlin While Loop Kotlin 19-11-2017
Kotlin When Statement Kotlin 18-11-2017
Kotlin Nested If Kotlin 18-11-2017
Kotlin If Else If Statement Kotlin 22-09-2018
Kotlin If Statement Kotlin 17-11-2017
Kotlin Print And Println Kotlin 22-09-2018
Kotlin Type Conversion Kotlin 17-11-2017
Kotlin Logical Operators Kotlin 17-11-2017
Kotlin Assignment Operators Kotlin 15-11-2017
Kotlin Data Types Kotlin 12-11-2017
Kotlin Variables Example Kotlin 11-11-2017
Kotlin Comments Example Kotlin 11-11-2017
Kotlin Hello World Kotlin 11-11-2017

1