/* File: stats.c
 *
 * This file is compiled separately from findstats.c
 */

/* Header files needed by the code 
 * found in the functions defined
 * in this file
 */
#include <stdio.h>
#include "stats.h"

#define PI 3.14159

/* Function: Sum
   Returns the sum of x and y.
*/
int Sum (int x, int y) 
{
  return (x + y) ;
}


/* Function: Max 
   Returns the larger of x and y.
*/
int Max (int x, int y) 
{
   if (x > y) {
      return (x) ;
   } else {
      return (y) ;
   }
}


/* Function: Min
   Returns the smaller of x and y.
*/
int Min (int x, int y) 
{
   if (x < y) {
      return (x) ;
   } else {
      return (y) ;
   }
}

/* Function: Avg
   Returns the average of x and y.
   Note: Avg returns a *** double *** value.
*/
double Avg (int x, int y) 
{
   double average ;
   
   average = (x + y) / 2.0 ;
   return (average) ;
}

/* Function: Dist 
   Returns the absolute value of x - y.
*/
int Dist (int x, int y) 
{
   int distance ;

   distance = x - y ;
   if (distance < 0) {
      return (-distance) ;
   } else {
      return (distance) ;
   }
}

