Example description
/* nag_binomial_dist (g01bjc) Example Program.
 *
 * Copyright 2017 Numerical Algorithms Group.
 *
 * Mark 26.2, 2017.
 *
 */

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

int main(void)
{
  Integer exit_status = 0;
  Integer k, n;
  double plek, peqk, pgtk;
  double p;
  NagError fail;

  INIT_FAIL(fail);

  printf("nag_binomial_dist (g01bjc) Example Program Results\n");
  /* Skip heading in data file */
  scanf("%*[^\n] ");

  printf("\n");
  printf("   n     p      k     plek      pgtk      peqk\n\n");
  while ((scanf("%" NAG_IFMT " %lf %" NAG_IFMT "%*[^\n]", &n, &p, &k)) != EOF)
  {
    /* nag_binomial_dist (g01bjc).
     * Binomial distribution function
     */
    nag_binomial_dist(n, p, k, &plek, &pgtk, &peqk, &fail);
    if (fail.code != NE_NOERROR) {
      printf("Error from nag_binomial_dist (g01bjc)\n%s\n", fail.message);
      exit_status = 1;
      goto END;
    }
    printf("%5" NAG_IFMT "%8.3f%5" NAG_IFMT "%10.5f%10.5f%10.5f\n", n, p, k,
           plek, pgtk, peqk);
  }

END:
  return exit_status;
}