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

NAG CL Interface Introduction
Example description
/* nag_stat_prob_gamma (g01efc) 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 a, b, g, p;
  NagError fail;

  INIT_FAIL(fail);

  /* Skip heading in data file */
  scanf("%*[^\n]");
  printf("nag_stat_prob_gamma (g01efc) Example Program Results\n");
  printf(" Gamma deviate    Alpha     Beta    Lower tail prob.\n\n");
  while (scanf("%lf %lf %lf", &g, &a, &b) != EOF)
  {
    /* nag_stat_prob_gamma (g01efc).
     * Probabilities for the gamma distribution
     */
    p = nag_stat_prob_gamma(Nag_LowerTail, g, a, b, &fail);
    if (fail.code != NE_NOERROR) {
      printf("Error from nag_stat_prob_gamma (g01efc).\n%s\n", fail.message);
      exit_status = 1;
      goto END;
    }
    printf(" %9.2f%13.2f%9.2f%14.4f\n", g, a, b, p);
  }

END:
  return exit_status;
}