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

Kotlin Multiplication

Kotlin Multiplication Operator takes two numbers as operands and returns the product of these two numbers.

* symbol is used for Multiplication Operator.

Syntax

The syntax for Multiplication Operator is

</>
Copy
operand_1 * operand_2

The operands could be of any numeric datatype.

Examples

1. Multiplication of two integers

In the following example, we take two integers and find their product using Multiplication Operator.

Main.kt

</>
Copy
fun main() {
    var a = 10
    var b = 20
    var result = a * b
    println("a * b : $result")
}

Output

a * b : 200

2. Multiplication of different type values

In the following example, we shall multiply an Int and a Float number using Multiplication Operator.

The result of the Multiplication Operator would be Float in this case.

Main.kt

</>
Copy
fun main() {
    var a = 3.14
    var b = 20
    var result = a * b
    println("a * b : $result")
}

Output

a * b : 62.800000000000004

Conclusion

In this Kotlin Tutorial, we learned how to use Multiplication Operator to multiply given two numbers.