#include
Double the add (double a, double b);
{return a + b; }
Double sub (double a, double b);
{return a - b; }
Double mult (double a, double b);
{return a * b; }
Double div (double a, double b);
{if (fabs (b) & lt; 0.000001)
The return - 65536;
The else
Return a/b; }
Double calc (double a, b double, double (* (p1) ())
{
Return (* (p1) (a, b);
}
The main ()
{=10 double a, b=5;
Printf (" a + b=% 7.21 f \ n ", calc (add));
Printf (" a - b=% 7.21 f \ n ", calc (sub));
Printf (" a * b=% 7.21 f \ n ", calc (mult));
Printf (" a/b=% 7.21 f \ n ", calc (div));
Getch ();
}
CodePudding user response:
#include#include
#include
Double the add (double a, double b)
{return a + b; }
Double sub (double a, double b)
{return a - b; }
Double mult (double a, double b)
{return a * b; }
Double div (double a, double b)
{if (fabs (b) & lt; 0.000001)
The return - 65536;
The else
Return a/b; }
Double calc (double a, b double, double (* (p1) (double, double))
{
Return (* (p1) (a, b);
}
Void main ()
{
=10 double a, b=5;
Printf (" a + b=% 7.21 f \ n ", calc (a, b, add));
Printf (" a - b=% 7.21 f \ n ", calc (a, b, sub));
Printf (" a * b=% 7.21 f \ n ", calc (a, b, mult));
Printf (" a/b=% 7.21 f \ n ", calc (a, b, div));
Getch ();
}