From f605454b31e30245d6d9ecd6e92e2114e4eba9a9 Mon Sep 17 00:00:00 2001 From: Francis John Magallanes <60374264+Francis-Magallanes@users.noreply.github.com> Date: Sat, 17 Apr 2021 11:25:39 +0800 Subject: [PATCH] Update sum.c Finished tasks --- sum.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sum.c b/sum.c index 0ee167a..2cb16a0 100644 --- a/sum.c +++ b/sum.c @@ -1,7 +1,5 @@ #include - - /** Return the sum of values from a to b * @param a = start value * @param b = final value @@ -15,8 +13,12 @@ */ int series(int a, int b){ //Write code here - - return 0; //EDIT THIS + + int sum = 0; + int i; + + for (i = 0; i< (b-a+1); i++) sum = sum + (a + i); + return sum; //EDIT THIS } @@ -30,4 +32,4 @@ int main(void) { printf("The sum from %d to %d is %d\n",a,b,series(a,b)); return 0; -} \ No newline at end of file +}