Multiplication is one of the fundamental operations in mathematics and computing.
In C++, multiplying two numbers is straightforward and can be done using the * operator.
In this tutorial, we will explore how to multiply two numbers using C++.
To multiply two numbers in C++, we first need to declare two variables to hold the numbers we want to multiply.
We can use the int data type to declare integer variables, or we can use float or double data types to declare floating-point variables.
Let’s assume we want to multiply the numbers 2 and 3. We can declare two integer variables a and b and assign them the values of 2 and 3, respectively, as follows:
int a = 2;
int b = 3;
To perform the multiplication, we can use the * operator to multiply a and b and assign the result to a third variable c, as follows:
int c = a * b;
Now, the variable c will hold the value of the product of a and b, which is 6.
If we want to output the result to the console, we can use the cout object from the iostream library, as follows:
#include <iostream>
int main()
{
int a = 2;
int b = 3;
int c = a * b;
std::cout << c << std::endl;
return 0;
}
The cout object is used to output text to the console, and the << operator is used to insert the value of c into the output stream. The endl manipulator is used to insert a newline character at the end of the output.
When we run the above program, the output will be:
6
In conclusion, multiplying two numbers in C++ is a simple task that can be accomplished using the * operator.
We can declare two variables to hold the numbers we want to multiply, use the * operator to perform the multiplication, and assign the result to a third variable.
We can output the result to the console using the cout object from the iostream library.




