NAG Library Manual, Mark 30.2
Interfaces:  FL   CL   CPP   AD 

NAG CL Interface Introduction
Example description
/* nag_stat_prob_chisq (g01ecc) Example Program.
 *
 * Copyright 2024 Numerical Algorithms Group.
 *
 * Mark 30.2, 2024.
 */

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

int main(void) {
  Integer exit_status = 0;
  double df, prob, x;
  NagError fail;

  INIT_FAIL(fail);

  /* Skip heading in data file */
  scanf("%*[^\n]");
  printf("nag_stat_prob_chisq (g01ecc) Example Program Results\n");
  printf("  x      df     prob\n\n");
  while (scanf("%lf %lf", &x, &df) != EOF)
  {
    /* nag_stat_prob_chisq (g01ecc).
     * Probabilities for chi^2 distribution
     */
    prob = nag_stat_prob_chisq(Nag_LowerTail, x, df, &fail);
    if (fail.code != NE_NOERROR) {
      printf("Error from nag_stat_prob_chisq (g01ecc).\n%s\n", fail.message);
      exit_status = 1;
      goto END;
    }
    printf("%6.3f%8.3f%8.4f\n", x, df, prob);
  }

END:
  return exit_status;
}