|
|
@ -4,6 +4,7 @@ |
|
|
|
#include <stdlib.h> |
|
|
|
|
|
|
|
int* division_integer(int dividend, int divisor) { |
|
|
|
// division with 0 would cause errors |
|
|
|
if(divisor == 0) { |
|
|
|
return NULL; |
|
|
|
} |
|
|
@ -15,3 +16,33 @@ int* division_integer(int dividend, int divisor) { |
|
|
|
*result = dividend / divisor; |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
long* division_long(long dividend, long divisor) { |
|
|
|
// division with 0 would cause errors |
|
|
|
if(divisor == 0) { |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
long* result = malloc(sizeof(long)); |
|
|
|
*result = dividend / divisor; |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
double* division_double(double dividend, double divisor) { |
|
|
|
// division with 0 would cause errors |
|
|
|
if(divisor == 0) { |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
double* result = malloc(sizeof(double )); |
|
|
|
*result = dividend / divisor; |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
float* division_float(float dividend, float divisor) { |
|
|
|
// division with 0 would cause errors |
|
|
|
if(divisor == 0) { |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
float* result = malloc(sizeof(float)); |
|
|
|
*result = dividend / divisor; |
|
|
|
return result; |
|
|
|
} |