Your divisions won't probably do what you expect:
(2 / 3) == 0
Dividing int
with int
will result in int
.
Use float constants (2.0f / 3.0f)
Edit:
You still have the same problem with the other n / 2
.
And you should use %f
when printing floats: printf("first sum: %f\n",first);