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

NAG CL Interface Introduction
Example description
/* nag_stat_inv_cdf_beta (g01fec) Example Program.
 *
 * Copyright 2024 Numerical Algorithms Group.
 *
 * Mark 30.1, 2024.
 */

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

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

  INIT_FAIL(fail);

  /* Skip heading in data file */
  scanf("%*[^\n]");
  printf("nag_stat_inv_cdf_beta (g01fec) Example Program Results\n");
  printf(" Probability     A         B     Deviate\n\n");
  while (scanf("%lf %lf %lf", &p, &a, &b) != EOF)
  {
    tol = 0.0;
    /* nag_stat_inv_cdf_beta (g01fec).
     * Deviates for the beta distribution
     */
    x = nag_stat_inv_cdf_beta(p, a, b, tol, &fail);
    if (fail.code != NE_NOERROR) {
      printf("Error from nag_stat_inv_cdf_beta (g01fec).\n%s\n", fail.message);
      exit_status = 1;
      if (fail.code != NE_RES_NOT_ACC && fail.code != NE_SOL_NOT_CONV) {
        goto END;
      }
    }
    printf("%9.4f%10.3f%10.3f%10.4f\n", p, a, b, x);
  }

END:
  return exit_status;
}