// testing one function at two points, // using function pointer arguments to a function // #include #include double my_sqrt( double x) { return exp(log(x)/2); } typedef double (*Func)(double); void test( const char *s, Func f, Func g, double x) { double y1 = f(x); // or: (*f)(x) double y2 = g(x); printf( "%s %g %g %g\n", s, x, y1, y2); } int main( void) { test( "sqrt", my_sqrt, sqrt, 2); test( "sqrt", my_sqrt, sqrt, 10); } /* output: sqrt 2 1.41421 1.41421 sqrt 10 3.16228 3.16228 */