diff --git a/src/minirechner.c b/src/minirechner.c index 6a133f3..cbc13ef 100644 --- a/src/minirechner.c +++ b/src/minirechner.c @@ -25,4 +25,9 @@ float dividieren(float a, float b) { else { return a / b; } +} + +//rest +float rest(float a, float b) { + return fmod(a, b); } \ No newline at end of file diff --git a/src/minirechner.h b/src/minirechner.h index 8c4466f..a2c989f 100644 --- a/src/minirechner.h +++ b/src/minirechner.h @@ -5,5 +5,6 @@ float addieren(float a, float b); float subtrahieren(float a, float b); float multiplizieren(float a, float b); float dividieren(float a, float b); +float rest(float a, float b); #endif // MINIRECHNER_H diff --git a/test/test_minirechner.c b/test/test_minirechner.c index 88e1df2..8df2c71 100644 --- a/test/test_minirechner.c +++ b/test/test_minirechner.c @@ -100,4 +100,11 @@ void test_minitaschenrechner_0_durch_5(void) TEST_ASSERT_EQUAL(0, result); } +// test rest +void test_minitaschenrechner_14_rest_5(void) +{ + float result = rest(14, 5); + TEST_ASSERT_EQUAL(4, result); +} + #endif // TEST