In this post, we will learn how to multiply two numbers using the C++ Programming language.
This program asks the user to enter two numbers, then this program finds the product of two numbers using the arithmetic operator.
So, without further ado, let’s begin this tutorial.
C++ Program to Multiply Two Numbers
// C++ Program to Multiply Two Numbers #include <iostream> using namespace std; int main(){ int num1, num2, result; // Asking for input cout << "Enter the first number: "; cin >> num1; cout << "Enter the second number: "; cin >> num2; // Perform multiplication result = num1 * num2; // Displaying output cout << "Product of two numbers: " << result << endl; return 0; }
Output
Enter the first number: 5
Enter the second number: 7
Product of two numbers: 35
How Does This Program Work ?
int num1, num2, result;
In this program, we have declared three integer data type variables named num1, num2, and result.
// Asking for input cout << "Enter the first number: "; cin >> num1; cout << "Enter the second number: "; cin >> num2;
Now, the user is asked to enter two numbers. These numbers get stored in the num1 and num2 named variables.
// Perform multiplication result = num1 * num2;
We find the product of two numbers using the (*) operator. The product of two numbers gets stored in the result named variable.
// Displaying output cout << "Product of two numbers: " << result << endl;
At last, the product of two numbers is displayed on the screen using the cout statement.
Conclusion
I hope after going through this post, you understand how to multiply two numbers using the C++ Programming language.
If you have any doubt regarding the program, feel free to contact us in the comment section. We will be delighted to assist you.
Also Read: