0

the problem is you do not have an accumulator, this revised code should work

```
int Range (int start, int end, int divisor)
{
int range, counter, sum;
sum=0;
for (counter=start; counter<end; counter++)
{
sum= sum + counter;
}
range = sum / divisor;
return range;
}
```

note I just changed start to sum, because sum is what you are using to count, sum is what you add to counter, which changes. Before you would only have two digits add each time, wipping the previous result because start is the same and counter changes.

0

Eh, I don't wanna give it all for you, what I am saying, is make an if statement to check if the integer is divisible by your divisor first. If it is, accumulate it, if not, move on to the next number. If you don't understand this basic code, I suggest you read up on your books or look through the internet for some guides before coming here.

You

This article has been dead for over six months: Start a new discussion instead