Browse Source

Merge branch 'develop' of https://gitlab.cs.hs-fulda.de/fdai7812/theadmirals into develop

remotes/origin/develop
Leon Wolf 11 months ago
parent
commit
7e62086edd
  1. 12
      src/arithmeticDivision.c
  2. 2
      src/arithmeticDivision.h
  3. 2
      src/arithmeticMultiplication_Double.c
  4. 2
      src/arithmeticMultiplication_Float.c
  5. 2
      src/arithmeticMultiplication_Int.c

12
src/arithmeticDivision.c

@ -23,4 +23,16 @@ long* division_long(long dividend, long divisor) {
long* result = malloc(sizeof(long));
*result = dividend / divisor;
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);
double* division_double(double, double);
#endif //THEADMIRALS_ARITHMETICDIVISION_H

2
src/arithmeticMultiplication_Double.c

@ -5,7 +5,7 @@
double* multiplication_double(double a, double b) {
double* result = (double*)malloc(sizeof(double));
if (result == NULL) {
return NULL; // Handle memory allocation failure
return NULL;
}
*result = a * b; // we multiply a times b and the result gets saved in *result
return result;

2
src/arithmeticMultiplication_Float.c

@ -4,7 +4,7 @@
float* multiplication_float(float a, float b) {
float* result = (float*)malloc(sizeof(float));
if (result == NULL) {
return NULL; // Handle memory allocation failure
return NULL;
}
*result = a * b;
return result;

2
src/arithmeticMultiplication_Int.c

@ -6,7 +6,7 @@
int* multiplication_integer(int a, int b) {
int *result = (int*)malloc(sizeof(int));
if (result == NULL) {
// Handle memory allocation failure
return NULL;
}

Loading…
Cancel
Save