Hi,
There is this exercise which I have to make an own function in it.
It goes like this:
sum(n) = 1+2+3+...+n
Here is the code I wrote. I get a syntax error in line 14. also an error in line 13 which says that variabel "dsum" is unused!!
Where in program should I make changes? Appreciate it a alot if someone can give me a clue!
Code:#include<stdio.h> #include<stdlib.h> #include<stdbool.h> int sum(int i); int main() { printf("%d\n",sum(5)); return 0; } int sum(int i) { int r = 1; int dsum = 0; for(r<=i){ dsum += r; r++; } return sum; }