diff --git a/src/multiplication.c b/src/multiplication.c index cef7c1c..24be7fd 100644 --- a/src/multiplication.c +++ b/src/multiplication.c @@ -1,5 +1,7 @@ #include "multiplication.h" #include +#include + double multi( double ein1, double ein2) { @@ -33,6 +35,14 @@ int multiply_by_random(int num) { return num * random_factor; } +int multiply_string(const char* str, int factor) { + int len = strlen(str); + int result = 0; + for (int i = 0; i < len; i++) { + result += str[i] * factor; + } + return result; +} diff --git a/src/multiplication.h b/src/multiplication.h index 894f020..1e6fddf 100644 --- a/src/multiplication.h +++ b/src/multiplication.h @@ -8,6 +8,8 @@ int multiply_right_shift(int a, int b); int multiply_by_ten(int a); float multiply_by_percentage(float num, float percentage); int multiply_by_random(int num); +int multiply_string(const char* str, int factor); + #endif // MULTIPLICATION_H