#include "library.h" void speak(int N) { if (N < 0) { print("minus "); speak(-N); } else if (N == 0) print("zero"); else if (N == 1) print("one"); else if (N == 2) print("two"); else if (N == 3) print("three"); else if (N == 4) print("four"); else if (N == 5) print("five"); else if (N == 6) print("six"); else if (N == 7) print("seven"); else if (N == 8) print("eight"); else if (N == 9) print("nine"); else if (N == 10) print("ten"); else if (N == 11) print("eleven"); else if (N == 12) print("twelve"); else if (N == 13) print("thirteen"); else if (N == 14) print("fourteen"); else if (N == 15) print("fifteen"); else if (N == 16) print("sixteen"); else if (N == 17) print("seventeen"); else if (N == 18) print("eighteen"); else if (N == 19) print("nineteen"); else if (N == 20) print("twenty"); else if (N == 30) print("thirty"); else if (N == 40) print("forty"); else if (N == 50) print("fifty"); else if (N == 60) print("sixty"); else if (N == 70) print("seventy"); else if (N == 80) print("eighty"); else if (N == 90) print("ninety"); else if (N <= 99) { speak(N / 10 * 10); print("-"); speak(N % 10); } else if (N <= 999) { speak(N / 100); print(" hundred"); if (N % 100 != 0) { print(" and "); speak(N % 100); } } else if (N <= 999999) { speak(N / 1000); print(" thousand"); const int rest = N % 1000; if (rest == 0) { } else if (rest < 100) { print(" and "); speak(rest); } else { print(" "); speak(rest); } } else if (N <= 999999999) { speak(N / 1000000); print(" million"); const int rest = N % 1000000; if (rest == 0) { } else if (rest < 100) { print(" and "); speak(rest); } else { print(" "); speak(rest); } } else /* ints on this computer only go up to 2,147,483,647 */ { speak(N / 1000000000); print(" billion"); const int rest = N % 1000000000; if (rest == 0) { } else if (rest < 100) { print(" and "); speak(rest); } else { print(" "); speak(rest); } } } void main() { print("type numbers and I'll speak them.\n"); while (true) { print("? "); int number = read_int(); speak(number); print("\n"); } print("If you see this message, the computer is broken.\n"); }