how can I get absolute value for the double diff in this case?
double cos_delta(double x, double delta)
{
int n = 1; // n should start with 1 because it is the number of terms
double diff = cos_N(x, n ) - cos_N(x, n - 1); // n and n-1 instead of n-1 and n-2
********* here ************
while (diff > delta) { // fabs returns absolute value of a double
n++;
diff = cos_N(x, n ) - cos_N(x, n - 1);
}
printf("n = %d\n", n);
return cos_N(x, n);
}