Example description
/* nag_5pt_summary_stats (g01alc) 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, i, n;
  NagError fail;
  double *res = 0, *x = 0;

  INIT_FAIL(fail);

  printf("nag_5pt_summary_stats (g01alc) Example Program Results\n");
  /* Skip heading in data file */
  scanf("%*[^\n] ");
  scanf("%" NAG_IFMT " ", &n);
  if (n >= 5) {
    if (!(x = NAG_ALLOC(n, double)) || !(res = NAG_ALLOC(5, double)))
    {
      printf("Allocation failure\n");
      exit_status = -1;
      goto END;
    }
  }
  else {
    printf("Invalid n.\n");
    exit_status = 1;
    return exit_status;
  }
  for (i = 1; i <= n; ++i)
    scanf("%lf ", &x[i - 1]);
  /* nag_5pt_summary_stats (g01alc).
   * Five-point summary (median, hinges and extremes)
   */
  nag_5pt_summary_stats(n, x, res, &fail);
  if (fail.code != NE_NOERROR) {
    printf("Error from nag_5pt_summary_stats (g01alc).\n%s\n", fail.message);
    exit_status = 1;
    goto END;
  }

  printf("\n");
  printf(" Maximum     %16.4f\n", res[4]);
  printf(" Upper Hinge %16.4f\n", res[3]);
  printf(" Median      %16.4f\n", res[2]);
  printf(" Lower Hinge %16.4f\n", res[1]);
  printf(" Minimum     %16.4f\n", res[0]);
END:
  NAG_FREE(x);
  NAG_FREE(res);

  return exit_status;
}