Example description
/* nag_prob_non_central_f_dist (g01gdc) Example Program.
 *
 * Copyright 2017 Numerical Algorithms Group.
 *
 * NAG C Library
 *
 * Mark 26.2, 2017.
 */

#include <stdio.h>
#include <nag.h>
#include <nagg01.h>

int main(void)
{
  Integer exit_status = 0, max_iter;
  NagError fail;
  double df1, df2, f, lambda, prob, tol;

  INIT_FAIL(fail);

  printf("nag_prob_non_central_f_dist (g01gdc) Example Program Results\n");

  /* Skip heading in data file */
  scanf("%*[^\n]");

  printf("\n     f       df1     df2     lambda    prob\n\n");
  tol = 5e-6;
  max_iter = 50;
  while ((scanf("%lf %lf %lf %lf %*[^\n]", &f, &df1, &df2, &lambda)) != EOF) {
    /* nag_prob_non_central_f_dist (g01gdc).
     * Computes probabilities for the non-central F-distribution
     */
    prob = nag_prob_non_central_f_dist(f, df1, df2, lambda, tol, max_iter,
                                       &fail);
    if (fail.code != NE_NOERROR) {
      printf("Error from nag_prob_non_central_f_dist (g01gdc).\n%s\n",
             fail.message);
      exit_status = 1;
      goto END;
    }
    printf("%8.3f %8.3f %8.3f %8.3f %8.4f\n", f, df1, df2, lambda, prob);
  }
END:
  return exit_status;
}