C++ Program To Multiply Two Floating-Point Numbers
Last Updated :
03 Aug, 2023
Here, we will see how to multiply two floating-point numbers using the C++ program.
Floating point numbers are numbers that include both integer part and fractional parts represented in the form of decimal and exponential values. float data type is used to store floating point values.
For example
Input : A =1.2, B = 3.0
Output : 3.6
We can multiply two floating-point numbers in C++ by using Multiplication Operator (*)
C++ Program To Multiply Two Floating-Point Numbers
The two floating-point numbers are multiplied using the function that uses the arithmetic operator ( * ), and the product is stored in the variable product.
C++
#include <iostream>
using namespace std;
float mul_floatnumbers( float a, float b) { return a * b; }
int main()
{
float A = 1.2, B = 3.0, product;
product = mul_floatnumbers(A, B);
cout << product;
return 0;
}
|
Complexity Analysis
- Time Complexity: O(1)
- Auxiliary Space: O(1)
Refer to the complete article Multiplying Floating Point Numbers for more details.
Share your thoughts in the comments
Please Login to comment...