/* File: big.c This file uses lots and lots of functions. */ #include #include "genlib.h" #include "simpio.h" /* Prototypes for the functions we use. */ int sum (int x, int y) ; int max (int x, int y) ; int min (int x, int y) ; double avg (int x, int y) ; int dist (int x, int y) ; /* 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) ; } } main() { int a, b ; printf("Enter first number: ") ; a = GetInteger() ; printf("Enter second number: ") ; b = GetInteger() ; printf("\n") ; printf("The sum of %d and %d is: %d\n", a, b, sum(a, b) ) ; printf("The smaller of %d and %d is: %d\n", a, b, min(a, b) ) ; printf("The larger of %d and %d is: %d\n", a, b, max(a, b) ) ; printf("The average of %d and %d is: %f\n", a, b, avg(a, b) ) ; printf("The distance between %d and %d is: %d\n", a, b, dist(a, b) ) ; printf("That's all folks.\n") ; }