#include <iostream>
double multiply(double num1, double num2) {
if (num2 > 0) return num1 + multiply(num1, num2 - 1);
else if (num2 < 0) return -num1 + multiply(num1, num2 + 1);
return 0;
}
signed main() {
//2.2 * 2
std::cout << multiply(2.2, 2) << std::endl;
//4 * 2
std::cout << multiply(4, 2) << std::endl;
//-8 * 2
std::cout << multiply(-8, 2) << std::endl;
//0*1
std::cout << multiply(0, 1) << std::endl;
#include <iostream>
double multiply(double num1, double num2) {
if (num2 > 0) return num1 + multiply(num1, num2 - 1);
else if (num2 < 0) return -num1 + multiply(num1, num2 + 1);
return 0;
}
signed main() {
//2.2 * 2
std::cout << multiply(2.2, 2) << std::endl;
//4 * 2
std::cout << multiply(4, 2) << std::endl;
//-8 * 2
std::cout << multiply(-8, 2) << std::endl;
//0*1
std::cout << multiply(0, 1) << std::endl;
return 0;
}