C++ Program to Multiply two Numbers

In the previous article, we have discussed C++ Program to Remove all Non Alphabet Characters from a String. In this article, we will see C++ Program to Multiply two Numbers.

C++ Program to Multiply two Numbers

  • Write a C++ program to multiply two numbers using * arithmetic operator.

In this program, we are going to perform basic arithmetic operation of multiplying two integers using multiplication(*) operation. Multiplication is one of the five fundamental arithmetic operators supported by C++ programming language, which are addition(+), subtraction(-), multiplication(*), division(/) and modulus(%). Multiplication operator multiplies both operands and returns the result.

For Example:

6 * 5; will evaluate to 30.

C++ Program to Multiply Two Numbers

C++ Program to Multiply Two Numbers

// C++ program to find product of two numbers
#include <iostream>
using namespace std;
 
int main() {
    int x, y, product;
     
    cout << "Enter two integers\n";
    cin >> x >> y;
     
    // Multiplying x and y
    product = x*y;
    cout << "Product = " << product;
     
    return 0;
}

Output

Enter two integers
4 8
Product = 32

In above program, we first take two integers as input from user using cin and store it in variable x and y. Then we multiply x and y using * operator and store the result of multiplication in variable product. Then finally, we print the value of product on screen using cout.

Points to Remember

  • If both operands are integers, then the product of two operands is also an integer.
  • Multiplication operator have higher priority than addition and subtraction operator.

The comprehensive list of C++ Programs Examples covered in our pages are very useful for every beginners and experienced programmers. So, make use of these C++ Coding Exercises & hold a grip on the programming language.