Anon, just make your functions pure.
Decompose into simpler functions as much as necessary, implement loops with tail recursion, take advantage of ternary operator, short circuiting, and comma operator so each function only has the return statement.
I.E.: Print an integer as Roman numeral.
typedef struct {const char* str; int v;} RomanPair;
static const RomanPair romanPairs[] =
{{"M", 1000}, {"CM", 900}, {"D", 500}, {"CD", 400},
{"C", 100}, {"XC", 90}, {"L", 50}, {"XL", 40},
{"X", 10}, {"IX", 9}, {"V", 5}, {"IV", 4},
{"I", 1}, {0, 0}};
#include <stdio.h>
static int printRomanPair(int n, const RomanPair* p) {
return p->v && n > 0 &&
(n < p->v ? !++p : printf((n -= p->v, p->str)),
printRomanPair(n, p));
}
static int printAsRoman(int n) {
return printRomanPair(n, romanPairs);
}
static int test(int n, int max) {
return n < max && (
printf("%i : ", n),
printAsRoman(n),
putchar('\n'),
test(n + 1, max));
}
int main() {
return test(1, 4000);
}