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

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

int main(void)
{
  Integer exit_status = 0;
  double p;
  double dev;
  Integer i;
  char nag_enum_arg[40];
  Nag_TailProbability tail;
  NagError fail;

  INIT_FAIL(fail);

  printf("nag_deviates_normal (g01fac) Example Program Results\n");
  /* Skip heading in data file */
  scanf("%*[^\n] ");
  printf("\n          Tail           Probability     Deviate \n\n");
  for (i = 1; i <= 4; ++i) {
    scanf("%39s %lf ", nag_enum_arg, &p);
    /* nag_enum_name_to_value (x04nac).
     * Converts NAG enum member name to value
     */
    tail = (Nag_TailProbability) nag_enum_name_to_value(nag_enum_arg);

    /* nag_deviates_normal (g01fac).
     * Deviates for the Normal distribution
     */
    dev = nag_deviates_normal(tail, p, &fail);
    if (fail.code != NE_NOERROR) {
      printf("Error from nag_deviates_normal (g01fac).\n%s\n", fail.message);
      exit_status = 1;
      goto END;
    }
    printf(" %-17s         %5.3f         %6.4f\n", nag_enum_arg, p, dev);
  }

END:

  return exit_status;
}