#include #include double sqrt5function(double x) { return x * x - 5; } int main() { extern double secant(double (*f)(double)); printf("%g\n", secant(sqrt5function)); return 0; } double secant(double (*f)(double)) { double x = 1, oldx = 2; while (fabs((*f)(x)) > 1e-5) { double newx = x - (*f)(x) * (x - oldx) / ((*f)(x) - (*f)(oldx)); oldx = x; x = newx; } return x; }