From 8a60c03078006d2f1eb9fe97ba626028c828fa77 Mon Sep 17 00:00:00 2001 From: fdai7930 Date: Thu, 8 Feb 2024 00:05:03 +0100 Subject: [PATCH] multiplication by percentage --- src/multiplication.c | 3 +++ src/multiplication.h | 1 + 2 files changed, 4 insertions(+) diff --git a/src/multiplication.c b/src/multiplication.c index bf381f4..0bb5f0e 100644 --- a/src/multiplication.c +++ b/src/multiplication.c @@ -24,6 +24,9 @@ int multiply_by_ten(int a) { return a * 10; } +float multiply_by_percentage(float num, float percentage) { + return num * (percentage / 100); +} diff --git a/src/multiplication.h b/src/multiplication.h index 5d0b41c..9f09f48 100644 --- a/src/multiplication.h +++ b/src/multiplication.h @@ -6,5 +6,6 @@ int multiply_three_integers(int a, int b, int c); 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); #endif // MULTIPLICATION_H