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