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

NAG CL Interface Introduction
Example description
/* nag_stat_prob_normal (g01eac) Example Program.
 *
 * Copyright 2024 Numerical Algorithms Group.
 *
 * Mark 30.0, 2024.
 *
 */

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

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

  INIT_FAIL(fail);

  printf("nag_stat_prob_normal (g01eac) Example Program Results\n");

  /* Skip heading in data file */
  scanf("%*[^\n] ");

  printf("\n     Tail               X      Probability \n\n");
  for (i = 1; i <= 4; ++i) {
    scanf("%39s %lf ", nag_enum_arg, &x);
    /* 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_stat_prob_normal (g01eac).
     * Probabilities for the standard Normal distribution
     */
    prob = nag_stat_prob_normal(tail, x, &fail);
    if (fail.code != NE_NOERROR) {
      printf("Error from nag_stat_prob_normal (g01eac).\n%s\n", fail.message);
      exit_status = 1;
      goto END;
    }
    printf(" %-17s    %4.2f       %6.4f\n", nag_enum_arg, x, prob);
  }

END:
  return exit_status;
}