write a program that multiplies two integer numbers without using the * operator , using repeated addition
Answers
Answered by
6
Answer:
return a;
- if (a == 1) return b; return a + mul(a, b - 1);
- } int multiply(int a, int b) { int m = mul(a, abs(b));
- return (b < 0) ? - m : m; } int main() {
- cout << multiply(3, 4) << " " << multiply(-3, -4) << " " << multiply(-3, 4) << " " << multiply(3, -4); return 0; }
Similar questions