/* File: sep2.c * * This file is compiled separately from sep1.c */ /* Prototypes for the functions we use. */ #include #include "math.h" #include "mine.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) ; } } /* Function: print_cos_avg Print the cosine of the average of x and y. */ void print_cos_avg (int x, int y) { double average ; average = avg(x,y) ; printf("Cosine of the average of %d and %d: %f\n", x, y, cos(PI * average / 180.0) ) ; }