/*
  How to write and call a Gauss function in C.
*/

#include <stdio.h>
#include <math.h>

double x,y;

double gauss(x, u, sd)      /*  Gauss Function Declaration  */
double x, u, sd;
{
  double c, TEMP;

  c = 1.0 / (sd * sqrt(2.0 * 3.14159));
  TEMP = x - u;
  return (c * exp(TEMP * TEMP / (-2.0 * sd * sd)));
} /*  End of Gauss function  */

main()
{
  /*  Declaration Statements  */
  int i;

  printf("C68.C -> This program implements a Gauss function call in C\n\n");

  /*  Assignment Statements  */
  for(i=0 ; i<=10 ; i=i++)
  {
  y = 5.0 * gauss(x, 0.0, 1.0) + 2.5;  /*  Call of Gauss function */

  /*  Print result  */
  printf("% .5E    % .5E\n",x,y);

  x = x + 0.5;  /*  Increase x by 0.5 for each loop  */

  } /*  End of for{} loop  */

  return(0);
}
/*  End of main Program C68  */