From 7592aad08c6245e0f4fbca7d900ad16c6171218a Mon Sep 17 00:00:00 2001 From: Eric Bagus Date: Thu, 8 Feb 2024 19:47:33 +0100 Subject: [PATCH] Expanded arithmetic division by long datatype --- src/arithmeticDivision.c | 9 +++++++++ src/arithmeticDivision.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/arithmeticDivision.c b/src/arithmeticDivision.c index 7cdfc7e..34949dd 100644 --- a/src/arithmeticDivision.c +++ b/src/arithmeticDivision.c @@ -14,4 +14,13 @@ int* division_integer(int dividend, int divisor) { int* result = malloc(sizeof(int)); *result = dividend / divisor; return result; +} + +long* division_long(long num1, long num2) { + if(num2 == 0) { + return NULL; + } + long* result = malloc(sizeof(long)); + *result = num1 / num2; + return result; } \ No newline at end of file diff --git a/src/arithmeticDivision.h b/src/arithmeticDivision.h index e4080b7..08bc4f5 100644 --- a/src/arithmeticDivision.h +++ b/src/arithmeticDivision.h @@ -3,4 +3,6 @@ int* division_integer(int, int); +long* division_long(long, long); + #endif //THEADMIRALS_ARITHMETICDIVISION_H