Hi, I'm relatively new to c, and understand most of the basics, but I'm have a problem with while and for loops in trying to implement an arithmetic series.

I thought something like:

Code:
float sum=0.0;
for(x=0;x<=5;x++)
  {
  sum+=a+(b*x);
  return sum;
  }
printf("sum of series = %f\n",sum)
-where variables have been declared before hand - would produce the equivalent of the mathematical series:

sum=a+(a+b)+(a+2b)+(a+3b)+(a+4b)+(a+5b)

..since everything I have read about for loops, says that the block of code between the curly parenthesis is executed repeatedly, for each value of x (startign at 0 and incrementing by one per iteration) , until the condition x<=5 is true.

By having the variable 'sum' that is initially 0, incrementing this value by 'a+(b*x)' for each iteration, and using 'return sum;' at the end of each iteration, I would have thought that on each loop between x=0 and x=5, the value a+xb would be added to 'sum' and then this new value returned back to the program, becoming the new value of 'sum' for the next iteration...such that when the loop has finished, the above series is yielded.

I have compiled this code sucessfully, and yet when I run it there is no output....i.e nothing gets printed.

What is wrong with this? thanks