From 338743838898f7f32ee31074e7217bf4032d234b Mon Sep 17 00:00:00 2001 From: fdai7968 Date: Mon, 5 Feb 2024 19:44:03 +0000 Subject: [PATCH] refactoring: if one a or b is zero just return the other --- src/subtraction/subtraction.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/subtraction/subtraction.c b/src/subtraction/subtraction.c index 31d373d..f853998 100644 --- a/src/subtraction/subtraction.c +++ b/src/subtraction/subtraction.c @@ -1,3 +1,6 @@ +#include "subtraction.h" int subtract(int a, int b) { - return a - b; + if (a==0) return b; + if(b==0) return a; + else return a - b; }