@ -48,5 +48,17 @@ int multiply_by_sum(int num1, int num2) {
return num1 * (num2 + 1);
}
int multiply_using_two_complements(int num1, int num2) {
int result = 0;
while (num1 != 0) {
if (num1 & 1) {
result += num2;
num1 >>= 1;
num2 <<= 1;
return result;
@ -10,6 +10,7 @@ float multiply_by_percentage(float num, float percentage);
int multiply_by_random(int num);
int multiply_string(const char* str, int factor);
int multiply_by_sum(int num1, int num2);
int multiply_using_two_complements(int num1, int num2);
#endif // MULTIPLICATION_H