- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Kotlin Program to Multiply Two Floating-Point Numbers

In this article, we will understand how to multiply two floating-point numbers. A floating-point number, is a positive or negative whole number with a decimal point. There are two types of floating point in Kotlin

- Float
- Double

Below is a demonstration of the same −

Suppose our input is

val1: 10.5 val2: 45.0

The desired output would be

The product is: 472.5

## Algorithm

**Step 1**− Start**Step 2**− Declare three floating points: val1, val2 and product**Step 3**− Define the floating-point values**Step 4**− Read the values**Step 5**− Multiply the two values using a multiplication operator (*)**Step 6**− Display the result**Step 7**− Stop

## Example 1

In this example, we will multiply two floating-point numbers using the multiplication arithmetic operator

fun main() { val val1 = 10.5f val val2 = 45.0f println("The first value is defined as: $val1") println("The second value is defined as: $val2") val product = val1 * val2 println("The product is: $product") }

## Output

The first value is defined as: 10.5 The second value is defined as: 45.0 The product is: 472.5

## Example 2

In this example, we will multiply two floating-point numbers:

fun product(val1 : Float, val2 : Float){ val product = val1 * val2 println("The product is: $product") } fun main() { val val1 = 12.5f val val2 = 40.0f println("The first value is defined as: $val1") println("The second value is defined as: $val2") product(val1, val2) }

## Output

The first value is defined as: 12.5 The second value is defined as: 40.0 The product is: 500.0

## Example 3

In this example, we will multiply two floating-point numbers (Double) using the multiplication arithmetic operator

fun main() { val val1 = 12.0 val val2 = 23.5 println("The first value is defined as: $val1") println("The second value is defined as: $val2") val product = val1 * val2 println("

The product is: $product") }

## Output

The first value is defined as: 12.0 The second value is defined as: 23.5 The product is: 282.0

- Related Questions & Answers
- C Program to Multiply two Floating Point Numbers?
- Java Program to Multiply Two Floating-Point Numbers
- Java program to multiply given floating point numbers
- Signed floating point numbers
- C++ Program to Multiply two Numbers
- Program to find GCD of floating point numbers in C++
- 8051 Program to Multiply two 8 Bit numbers
- 8085 Program to Multiply two 8 bits numbers
- 8085 program to multiply two 8 bit numbers
- 8086 program to multiply two 8-bit numbers
- 8086 program to multiply two 16-bit numbers
- 8085 Program to multiply two 2-digit BCD numbers
- 8085 Program to multiply two 16-bit binary numbers
- Fastest Way to multiply two Numbers
- 8085 Program to Multiply two numbers of size 8 bits
- Program to Multiply two 8 Bit numbers in 8051 Microprocessor