/*------------------------------------------------------------*/
/*  Program solution to hw2                                   */
/*                                                            */
/*  This program computes for the formula in HW 2             */

/* Get required libraries */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

/* Define a contant for PI */
#define PI 3.14

int main(void)
{
   /*  Declare and initialize variables.  */
   double t, mu, sigma, f_t;
   
   /* Get values for variables from the user */
   printf("Enter values for t, mu and sigma.\n" );
   printf(" t: ");
   scanf("%lf", &t);
   printf("\n mu: ");
   scanf("%lf", &mu);
   printf("\n sigma: ");
   scanf("%lf", &sigma);
   
   /* Check to make sure user didn't enter a zero for sigma */
   if ( 0 == sigma )
   {
   	  		 printf("Sigma cannot be zero. Please re-enter.\n");
			 return -1;
   }
   
   /* Calculate f(t) using supplied formula*/
   f_t = (1/(sigma*sqrt(2*PI)))*exp(-pow(t-mu, 2)/(2*pow(sigma, 2)));

   /*  Print f(t) to the user  */
   printf("\nf(t) = %5.5f \n\n",f_t);
   
   //system("pause");
   /*   Exit program.  */
   return 0;
}
