/** * avetestB.c - An non-interactive test of the average procedure. */ #include #include #include #include "average.h" /** * Procedure: * report * Parameters * values, an array of integers * count, an integer * Purpose: * Prints a simple report on the average value in values * Produces: * [Nothing; Called for the side effect.] * Pre: * values[] contains at least count values * count > 0 */ void report (int values[], int count) { int i; printf ("average ({%d", values[0]); for (i = 1; i < count; i++) { printf (",%d", values[i]); } // for printf ("}) = %d.\n", average(values, count)); } // report int main () { int i; int values0[] = { 1, 2, 3, 4, 5 }; int values1[] = { 5, 1, 3, 4, 2 }; int values2[] = { 99, 1042, 78, 452 }; int values3[] = { -5, -8, -7, -6, 5 }; // A simple test report (values0, 5); report (values2, 4); report (values3, 5); // Lots of tests for (i = 1; i <= 5; i++) report (values1, i); // And we're done return EXIT_SUCCESS; } // main