In this tutorial, you shall learn about Division operator in Kotlin, its syntax, and how to use Division operator in programs, with examples.

Kotlin Division

Kotlin Division Operator takes two numbers as operands, divides the first number by the second number, and returns the quotient of this division operation.

/ symbol is used for Division Operator.

Syntax

The syntax for Division Operator is

</>
Copy
operand_1 / operand_2

The operands could be of any numeric datatype.

Examples

1. Division with two numbers

In the following example, we take two integers: a and b, and find the quotient of the division: a divided by b, using Division Operator.

Main.kt

</>
Copy
fun main() {
    var a = 20
    var b = 3
    var quotient = a / b
    println("Quotient : $quotient")
}

Output

Quotient : 6

2. Division with numbers of different types

In the following example, we divide a Float number by an Int number using Division Operator.

Main.kt

</>
Copy
fun main() {
    var a = 22.7
    var b = 3
    var quotient = a / b
    println("Quotient : $quotient")
}

Output

Quotient : 7.566666666666666

Conclusion

In this Kotlin Tutorial, we learned how to use Division Operator to find the quotient in the division of a number by another number.