C++ Program to Multiply two Numbers

284
views
product of numbers
(Last Updated On: September 1, 2018)

In this example, you’ll learn to find the product of numbers in C++ Programming.

In this program, the user is asked to enter two numbers (floating point numbers). Then, the product of those two numbers or product of numbers is stored in a variable and displayed on the screen.

Here user enters the numbers the first number is stored in “a” and the second number in “b” and the Product is stored in productOfNumbers

#include <iostream>
using namespace std;

int main()
{
    double a, b, productOfNumbers;
    cout << "Enter two numbers: ";

    // Stores both floating point numbers in variable a and b respectively
    cin >> a >> b;
 
    // Performs multiplication and stores the result in variable productOfNumbers
    productOfNumbers = a * b;  

    cout << "Product = " << productOfNumbers;    
    
    return 0;
}

Output

Enter two numbers: 3.4
5.5
Product = 18.7

In this program, the user is asked to enter two numbers. These two numbers entered by the user is stored in a variable a and b respectively.

Then, the product of a and b is evaluated and the result is stored in variable productOfNumbers.

Finally, the productOfNumbers is displayed on the screen.

Here are few Related CPP Program

Ask your questions and clarify your/others doubts about the product of numbers by commenting. Documentation.

Please write to us at [email protected] to report any issue with the above content or for feedback.