Browse Source

refactoring: implemented descriptions for methods in arithmetic addition

remotes/origin/develop
Eric Bagus 11 months ago
parent
commit
6c33f586e6
  1. 4
      src/arithmeticAddition.c

4
src/arithmeticAddition.c

@ -3,6 +3,7 @@
#include <limits.h>
#include <stdlib.h>
// addition for two integer inputs (no decimal number)
int* addition_integer(int num1, int num2) {
if ((num2 > 0 && num1 > INT_MAX - num2) || (num2 < 0 && num1 < INT_MIN - num2)) {
return NULL;
@ -12,18 +13,21 @@ int* addition_integer(int num1, int num2) {
return result;
}
// addition for two double inputs (decimal number)
double* addition_double(double num1, double num2) {
double* result = malloc(sizeof(double));
*result = num1+num2;
return result;
}
// addition for two float inputs (decimal number)
float* addition_float(float num1, float num2) {
float* result = malloc(sizeof(float));
*result = num1+num2;
return result;
}
// addition for two long inputs (no decimal number)
long* addition_long(long num1, long num2) {
long* result = malloc(sizeof(long));
*result = num1+num2;

Loading…
Cancel
Save