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 +}