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

NAG CL Interface Introduction
Example description
/* nag_stat_inv_cdf_chisq (g01fcc) Example Program.
 *
 * Copyright 2022 Numerical Algorithms Group.
 *
 * Mark 28.4, 2022.
 */

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

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

  INIT_FAIL(fail);

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

END:
  return exit_status;
}