How to multiply two numbers without using the multiple operator (*) in C++

1 Answer

0 votes
#include <iostream>

using namespace std;

int main()
{
	int a = 3, b = 9, mul = 0;

	// mul = a * b

	for (int i = 1; i <= a; i++)
		mul = mul + b;

	cout << a << " * " << b << " = " << mul << endl;

	return 0;
}

/*
run:

3 * 9 = 27

*/

 



answered Mar 21, 2016 by avibootz
edited Mar 22, 2016 by avibootz
...