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

NAG CL Interface Introduction
Example description
/* nag_stat_prob_students_t (g01ebc) Example Program.
 *
 * Copyright 2022 Numerical Algorithms Group.
 *
 * Mark 28.3, 2022.
 *
 */

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

int main(void) {
  Integer exit_status = 0;
  double df, prob, t;
  int i;
  static Nag_TailProbability tail[4] = {Nag_LowerTail, Nag_UpperTail,
                                        Nag_TwoTailSignif, Nag_TwoTailConfid};
  static const char *tailmess[] = {"Nag_LowerTail", "Nag_UpperTail",
                                   "Nag_TwoTailSignif", "Nag_TwoTailConfid"};
  NagError fail;

  INIT_FAIL(fail);

  printf("nag_stat_prob_students_t (g01ebc) Example Program Results\n\n");
  /* Skip heading in data file */
  scanf("%*[^\n]");
  printf("    t      df     prob      tail\n\n");
  while (scanf("%lf %lf %d\n", &t, &df, &i) != EOF)
  {
    /* nag_stat_prob_students_t (g01ebc).
     * Probabilities for Student's t-distribution
     */
    prob = nag_stat_prob_students_t(tail[i], t, df, &fail);
    if (fail.code != NE_NOERROR) {
      printf("Error from nag_stat_prob_students_t (g01ebc).\n%s\n",
             fail.message);
      exit_status = 1;
      goto END;
    }
    printf(" %6.3f%8.3f%8.4f  %s\n", t, df, prob, tailmess[i]);
  }

END:
  return exit_status;
}