In C++, multiplication is performed with the arithmetic multiplication operator *. This tutorial explains integer, floating-point, mixed-type, character, and Boolean multiplication, along with chained multiplication and the *= multiplication assignment operator.

C++ Multiplication Operator Syntax

The multiplication operator * is a binary arithmetic operator. It takes a left operand and a right operand and produces their product.

</>
Copy
result = left_operand * right_operand;

For example, 6 * 4 evaluates to 24. The operands can be literals, variables, or arithmetic expressions, provided their types support multiplication.

1. Multiplication of Integers in C++

You can multiply two integers using the multiplication operator. When both operands are int, the multiplication expression is evaluated using integer arithmetic after the applicable integer promotions.

</>
Copy
int = int * int

In the following program, two integer variables are initialized and multiplied using the * operator.

C++ Program

</>
Copy
#include <iostream>  
using namespace std;

int main() {
   int a = 12;
   int b = 7;

   int product = a * b;

   cout << product << endl;
}

Output

84

The expression a * b evaluates 12 * 7, so 84 is stored in product.

2. Multiplication of Floating Point Numbers in C++

You can multiply two floating-point numbers using the same * operator. When both operands are float, their product can be stored in a float.

</>
Copy
float = float * float

In the following program, two floating-point variables are multiplied.

C++ Program

</>
Copy
#include <iostream>  
using namespace std;

int main() {
   float a = 1.2;
   float b = 0.6;

   float product = a * b;

   cout << product << endl;
}

Output

0.72

Floating-point numbers are stored using finite binary representations, so some decimal products may show small rounding differences when printed with greater precision. This is normal floating-point behavior.

3. Multiplication of Integer and Floating Point Number in C++

C++ also allows multiplication between different arithmetic types. When an int is multiplied by a float, the integer operand is converted to a compatible floating-point type as part of the usual arithmetic conversions.

</>
Copy
float = int * float

In the following program, the integer value 2 is multiplied by the floating-point value 1.3.

C++ Program

</>
Copy
#include <iostream>  
using namespace std;

int main() {
   int a = 2;
   float b = 1.3;

   float product = a * b;

   cout << product << endl;
}

Output

2.6

4. Multiplication of Character Values in C++

Character types are integral types in C++. Before multiplication, char operands normally undergo integral promotion. Therefore, an expression such as ch1 * ch2 is usually evaluated as integer multiplication, even if the result is later assigned to a char.

</>
Copy
char = char * char

The syntax above shows a multiplication result being assigned to a char; it does not mean that the multiplication expression itself necessarily has type char.

In the following program, ch1 contains the numeric character-type value 9 and ch2 contains 8. After integral promotion, their product is 72. Assigning that value to ch and printing it as a character produces the character associated with code value 72 in the implementation’s execution character set.

C++ Program

</>
Copy
#include <iostream>  
using namespace std;

int main() {
   char ch1 = 9;
   char ch2 = 8;

   char ch = ch1 * ch2;

   cout << ch << endl;
}

Output

H

For ordinary numeric multiplication of character values, storing the product in an int is clearer and avoids converting the numeric result back to a character type.

5. Multiplication of Boolean Values in C++

A bool is an integral type. In arithmetic expressions, false is promoted to 0 and true is promoted to 1 before multiplication is performed.

</>
Copy
bool = bool * bool

The expression bool * bool is evaluated using promoted integer values. If the resulting integer is assigned back to bool, zero becomes false and a nonzero value becomes true.

For operands that are strictly Boolean values, multiplication followed by conversion back to bool gives the same truth result as logical AND: only true * true produces a nonzero value. In normal Boolean code, however, && expresses logical AND more clearly and also has short-circuit behavior, which arithmetic multiplication does not provide.

In the following program, true becomes 1, false becomes 0, and 1 * 0 evaluates to 0.

C++ Program

</>
Copy
#include <iostream>  
using namespace std;

int main() {
   bool a = true;
   bool b = false;

   bool c = a * b;

   cout << c << endl;
}

Output

0

Chaining the C++ Multiplication Operator

You can chain the multiplication operator to multiply more than two operands in one expression. Multiplication is left-associative, so an expression containing only multiplication operators is grouped from left to right.

</>
Copy
result = operand_1 * operand_2 * operand_3 * ... * operand_n

For example, a * b * c is grouped as (a * b) * c. For ordinary exact integer multiplication without overflow, this produces the expected mathematical product.

In the following example, four integer variables are multiplied in a single expression.

C++ Program

</>
Copy
#include <iostream>  
using namespace std;

int main() {
   int a = 12;
   int b = 25;
   int c = 61;
   int d = 37;

   int product = a * b * c * d;

   cout << product << endl;
}

Output

677100

The calculation is 12 * 25 * 61 * 37, which produces 677100.

C++ Multiplication Assignment Operator *=

The compound multiplication assignment operator *= multiplies the value on the left by the value on the right and assigns the result back to the left-hand object.

</>
Copy
variable *= value;

For a simple variable, price *= 2; means that price is multiplied by 2 and updated with the resulting value.

</>
Copy
#include <iostream>
using namespace std;

int main() {
    int value = 6;
    value *= 4;

    cout << value << endl;

    return 0;
}

Output

24

Multiply Two User-Entered Numbers in C++

When the values are not known in advance, you can read two numbers with cin, multiply them, and print their product. Using double allows the example to accept both whole-number and decimal input.

</>
Copy
#include <iostream>
using namespace std;

int main() {
    double first;
    double second;

    cin >> first >> second;

    double product = first * second;
    cout << product << endl;

    return 0;
}

If the input is 5 and 2.5, the product is 12.5.

12.5

C++ Multiplication Using a Function

Multiplication can also be placed inside a function when the same calculation needs to be reused. The multiplication operator itself works exactly the same way; the function simply organizes the operation into a reusable unit.

</>
Copy
#include <iostream>
using namespace std;

int multiply(int a, int b) {
    return a * b;
}

int main() {
    cout << multiply(7, 6) << endl;
    return 0;
}

Output

42

C++ Multiplication in Arithmetic Expressions

Multiplication has higher precedence than addition and subtraction. Therefore, in an expression such as 2 + 3 * 4, the multiplication is evaluated before the addition.

</>
Copy
#include <iostream>
using namespace std;

int main() {
    int a = 2 + 3 * 4;
    int b = (2 + 3) * 4;

    cout << a << endl;
    cout << b << endl;

    return 0;
}

Output

14
20

Parentheses can be used when you want another part of the expression evaluated first.

Type Conversion During C++ Multiplication

The type used for a multiplication expression depends on the operand types and the usual arithmetic conversions. This is important when different numeric types appear in the same expression.

  • int * int: the multiplication is performed using an appropriate integer type after integer promotions.
  • int * float: the integer is converted so that multiplication can be performed using a compatible floating-point type.
  • float * double: the operands are converted to a common floating-point type suitable for the operation.
  • char and bool operands: these undergo integral promotion before ordinary arithmetic multiplication.

The type of the variable that receives the result is a separate matter. A multiplication expression may be evaluated in one type and then converted when assigned to another type.

Integer Overflow in C++ Multiplication

Multiplying two integer values can produce a mathematical result that does not fit in the type used for the expression. For signed integer types, overflow is not a valid way to obtain a wrapped numeric result and must be avoided. Unsigned arithmetic is defined modulo the range of the unsigned type, but that wrapped value may still be undesirable for the program’s logic.

If the expected product can be large, use a type with a sufficient range and make sure the multiplication is performed in that wider type. Merely assigning an already-overflowed integer expression to a wider variable does not repair the calculation.

</>
Copy
#include <iostream>
using namespace std;

int main() {
    int a = 100000;
    int b = 100000;

    long long product = 1LL * a * b;

    cout << product << endl;
    return 0;
}

Output

10000000000

The literal 1LL causes the multiplication to proceed using long long arithmetic from the beginning of the expression.

C++ Multiplication Examples by Operand Type

ExpressionOperationExample result
12 * 7Integer multiplication84
1.2f * 0.6fFloating-point multiplicationApproximately 0.72
2 * 1.3fMixed integer and floating-point multiplicationApproximately 2.6
value *= 4Multiply and assignUpdates value
2 + 3 * 4Multiplication before addition14

C++ Multiplication Editorial QA Checklist

  • Verify that every basic multiplication example uses *, not the letter x.
  • Check that mixed int and floating-point examples explain the arithmetic conversion before multiplication.
  • For char and bool examples, distinguish integral promotion from the type used to store the final product.
  • Do not describe Boolean multiplication as a replacement for &&; arithmetic multiplication does not provide logical short-circuit evaluation.
  • Confirm that *= is described as multiplication followed by assignment to the left-hand object.
  • For chained integer multiplication, verify that the intermediate and final products fit the type used for the expression.
  • When demonstrating a wider result type, ensure the multiplication itself is promoted before a potentially overflowing narrower multiplication occurs.
  • Check multiplication inside larger arithmetic expressions for correct operator precedence and intentional use of parentheses.

C++ Multiplication Summary

In this C++ Tutorial, we learned how to use C++ Multiplication Operator on values of different datatypes, etc.

Use a * b to multiply two arithmetic operands in C++. The operand types determine the arithmetic conversions used for the expression, *= multiplies and updates a variable, multiplication takes precedence over addition and subtraction, and integer products must stay within the range of the type used for the calculation.