C++ Program to Multiply Twp Numbers Without * Operator

bookmark

#include <iostream>
 
int main()
{
    long op1, op2, product = 0;
 
    std::cout << "Enter the numbers ";
    std::cin >> op1 >> op2;
    while(op2 > 0)
    {
        product = product + op1;
        op2--;
    }
    std::cout << std::endl << "The product of " << op1
              << " and " << op2 << " is " << product;
}


output:
Enter the numbers 10 20
The product of 10 and 20 is 200