#include #include #include /* for log10 and pow */ void printd(int n); int main() { printd(12345); printf("\n"); return EXIT_SUCCESS; } /* Print a non-negative int in decimal. */ #if 0 void printd(int n) { int i; for (i = pow(10, (int)log10(n)); i >= 1; i /= 10) { printf("%d", n / i % 10); } } #endif void printd(int n) { /* If n has any digits in addition to the rightmost digit, */ if (n >= 10) { printd(n / 10); /* Print all but the rightmost digit of n. */ } printf("%d", n % 10); /* Print the rightmost digit of n. */ }