C++ Program to Multiply two Numbers

Here is 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

#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.

Recommended Posts
C++ Program to Add Two Numbers
C++ Program to Find Quotient and Remainder
C++ Program to Swap Two Numbers
C++ Program to Check Whether Number is Even or Odd
C++ Program to Find LCM and GCD of Two Numbers
C++ Program to Find Largest of Three Numbers
C++ Program to Find All Square Roots of a Quadratic Equation
C++ Program to Make a Simple Calculator
C++ Program to Find Sum of Natural Numbers
C++ Program to Calculate Standard Deviation
C++ Program to Check Leap Year
All C++ Programs