/* this is a quick rewrite of the multiplication table program so that it uses a function */ #include #include #define LOWER 0 /* the lower and upper limit for the multiplication table */ #define UPPER 12 int multiply( int x, int y ); int main() { int i, j, k, l; i = j = k = l = 0; for ( i = LOWER; i <= UPPER; ++i) printf("\t%d", i); printf("\n"); for ( i = LOWER; i <= UPPER; ++i) { printf("\t"); k = (log10(i)) + 1; /* k = number of digits, i */ for ( l = 0; l < k; ++l ) printf("-"); } printf("\n"); for ( i = LOWER; i <= UPPER; ++i) { printf("%2d |", i); for ( j = LOWER; j <= UPPER; ++j) { printf("\t%d", multiply(i,j)); } printf("\n"); } return 0; } int multiply( int x, int y) { return x*y; }