From d39998fe0f8907519a840a8fece598fc851377c4 Mon Sep 17 00:00:00 2001 From: fdai7930 Date: Thu, 8 Feb 2024 00:33:28 +0100 Subject: [PATCH] multiplication by random --- src/multiplication.c | 5 +++++ src/multiplication.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/multiplication.c b/src/multiplication.c index 0bb5f0e..cef7c1c 100644 --- a/src/multiplication.c +++ b/src/multiplication.c @@ -28,6 +28,11 @@ float multiply_by_percentage(float num, float percentage) { return num * (percentage / 100); } +int multiply_by_random(int num) { + int random_factor = rand() % 10 + 1; + return num * random_factor; +} + diff --git a/src/multiplication.h b/src/multiplication.h index 9f09f48..894f020 100644 --- a/src/multiplication.h +++ b/src/multiplication.h @@ -7,5 +7,7 @@ int multiply_left_shift(int a, int b); 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); + #endif // MULTIPLICATION_H