Find product of two floating point numbers in C++
- Home
- Calculations
- Find product of two floating point numbers in C++
- On
- By
- 0 Comment
- Categories: Calculations, multiply
Find product of two floating point numbers in C++
Find product of two floating point numbers in C++
In this tutorial, we will discuss the concept of Find product of two floating point numbers in C++
In this topic, we are going to learn how to multiply two floating-point numbers using the multiplication operator in C++ language
What is multiplication
The multiplication is a method of combining a group of equal size. The multiplication is an arithmetic operation inverse of division
It is one of the four basic operation of arithmetic calculation others being addition,subtraction,division
The multiplication of two natural numbers means, it is the operation one number is combining within another using multiply(*) operator.
The answer of a multiplication operation is called as “product”
Find product of two floating point numbers in C++
Program to product of two numbers
The program calculates the multiplication of the given floating-point numbers using multiplication operator in C++ language
Program 1
#include <iostream> #include <conio.h> using namespace std; int main() { double num1=3.2,num2=6.5,product; //declare and initialize double variables product=num1*num2; //Calculate product of two numbers cout<<"product of "<<num1<<" and "<<num2<<" is="<<product; //display output on the screen getch(); return 0; }
When the above code is executed, it produces the following result
Product of 3.2 and 6.5 is: 20.8
Program to product of two numbers – Takes input from user
The program allows the user to enter two floating-point numbers and then it calculates the multiplication of the given floating-point numbers using multiplication operator
Program 2
#include <iostream> #include <conio.h> using namespace std; int main() { double num1,num2,product; //declare double variables cout<<"Enter two numbers: "; //Ask input from the user cin>>num1>>num2; //store the input value to variables num1, num2 product=num1*num2; //Calculate product of two numbers cout<<"product of "<<num1<<" and "<<num2<<" is="<<product; //display output on the screen getch(); return 0; }
When the above code is executed, it produces the following result
Enter two numbers:2.4 4.2 Product of 2.4 and 4.2 is: 10.08
Suggested for you
Similar post
Find product of two numbers using function in C++ language
Find product of two numbers using recursion in C++ language
Multiply two numbers in C language
Multiply two numbers in Python language
Multiply two numbers in Java language
Multiply of two floating-point numbers in Java
Multiply of two floating-point numbers in C
Multiply of two floating-point numbers in C++
Multiply of two floating-point numbers in Python