/* * CISC105-12 class * 06.06.05 * average.c * Compute the average of three numbers. * - modified 06.13.05 to accept user input. * - modified 06.20.05 to use a function. */ #include double average( int x, int y, int z); int main() { int x = 4, y = 90, z = 100; printf("Enter 3 numbers: "); scanf("%d%d%d", &x, &y, &z); printf("The average of %d, %d, %d = %lf\n", x, y, z, average( x, y, z ) ); return 0; } /* * Input is three numbers. * Output is the average of the three numbers. */ double average( int x, int y, int z ) { int sum; double average; /* this is the sum of x, y, and z */ sum = x + y + z; /* I made the divisor 3.0 to do double division instead of integer division.*/ average = sum/3.0; return average; }