Browse Source

Implemented division for double values

remotes/origin/develop
Eric Bagus 11 months ago
parent
commit
81df1a1384
  1. 12
      src/arithmeticDivision.c
  2. 2
      src/arithmeticDivision.h

12
src/arithmeticDivision.c

@ -23,4 +23,16 @@ long* division_long(long dividend, long divisor) {
long* result = malloc(sizeof(long)); long* result = malloc(sizeof(long));
*result = dividend / divisor; *result = dividend / divisor;
return result; return result;
}
double* division_double(double num1, double num2) {
if(num2 == 0) {
return NULL;
}
double* result = malloc(sizeof(double ));
*result = num1 / num2;
return result;
} }

2
src/arithmeticDivision.h

@ -5,4 +5,6 @@ int* division_integer(int, int);
long* division_long(long, long); long* division_long(long, long);
double* division_double(double, double);
#endif //THEADMIRALS_ARITHMETICDIVISION_H #endif //THEADMIRALS_ARITHMETICDIVISION_H
Loading…
Cancel
Save