/* program to compute a circle's circumference and area example using an array
   of functions */

#include <stdio.h>
#include <math.h>

/* identity function (return the value given) */
double
identity (double radius)
{
  return radius;
} // identity


/* calculate the circumference of a circle given its radius */
double
circumference (double radius)
{
  return 2 * M_PI * radius;
} // circum


/* calculate the area of a circle given its radius */
double area (double radius)
{
  return M_PI * radius * radius;
} // area


/* main processing */
int
main (void)
{
  double (*funcArr[3]) (double) = {identity, circumference, area};
  printf ("      radius   circumference   area\n");
  for (double radius = 0; radius < 10; radius++)
  {
    for (int f = 0; f < 3; f++)
      printf ("%12.4lf", funcArr[f](radius));
    printf ("\n");
  }
  return 0;
} // main
