#include const string small_names[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" }; const string ty_words[] = { "", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninty" }; void say(const int n) { if (n>=0 && n<20) { print(small_names[n]); } else if (n<100) { const int dig1 = n / 10, dig2 = n % 10; print(ty_words[dig1]); if (dig2 != 0) { print("-"); say(dig2); } } else if (n<1000) { const int dig1 = n / 100; const int digs23 = n % 100; say(dig1); if (digs23 == 0) print(" hundred"); else { print(" hundred and "); say(digs23); } } else if (n < 1000000) { const int digs123 = n / 1000; const int digs456 = n % 1000; say(digs123); print(" thousand"); if (digs456 != 0) { if (digs456 < 100) print(" and"); print(" "); say(digs456); } } else if (n < 1000000000) { const int first6 = n / 1000000; const int last6 = n % 1000000; say(first6); print(" million"); if (last6 != 0) { if (last6 < 100) print(" and"); print(" "); say(last6); } } else if (n >= 1000000000) { const int first9 = n / 1000000000; const int last9 = n % 1000000000; say(first9); print(" billion"); if (last9 != 0) { if (last9 < 100) print(" and"); print(" "); say(last9); } } // no matter what I do after this point, // this function is guaranteed to work perfectly // for 0 to the maximum int value inclusive. else { print("minus "); say(- n); } } void main() { while (true) { print("number? "); const int x = read_int(); say(x); new_line(); } print("Bye!\n"); }