- What is the problem?
- What input do you use when the problem happens?
- What is your program supposed to do?
- Do you have a main() function to call sum?
- Have you defined abs()?
Your function "works" (returns a value) in the following scenario:
#include <stdio.h>
#define abs(x) (x) < 0 ? (x) : -(x)
double sum(double eps)
{
double a, s=0, p=-1, four=4,five=25;
while (1)
{
a=p/(four+five);
s+=a;
if (abs(a)<eps) return s;
p=-p;
four=four*4;
five=five*5;
}
}
int main()
{
printf("result: %lf\n", sum(0.2));
return 0;
}