You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
388 B

  1. #include "arithmeticDivision.h"
  2. #include <stdio.h>
  3. #include <limits.h>
  4. #include <stdlib.h>
  5. int* division_integer(int dividend, int divisor) {
  6. if(divisor == 0) {
  7. return NULL;
  8. }
  9. // Overflow protection
  10. if (dividend == INT_MIN && divisor == -1) {
  11. return NULL;
  12. }
  13. int* result = malloc(sizeof(int));
  14. *result = dividend / divisor;
  15. return result;
  16. }