Browse Source

multiplication string

remotes/origin/multiplication
fdai7930 11 months ago
parent
commit
b484b79f1f
  1. 10
      src/multiplication.c
  2. 2
      src/multiplication.h

10
src/multiplication.c

@ -1,5 +1,7 @@
#include "multiplication.h"
#include <stdio.h>
#include <string.h>
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;
}

2
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
Loading…
Cancel
Save