/* * Author : Amit Dutta * Date : 08 Feb 2026 * Repo : https://github.com/notamitgamer/bsc * License : MIT License (See the LICENSE file for details) */ /* Write a program that receives an integer (less than or equal to nine digits in length) and prints out the number in words. */ /* Let Us C, Chap- 16 (Handling Multiple Strings), Qn No.: A(f) */ /* This file is auto-generated by a bot. */ /* This code is not compiled; it is for reference only. */ #include #include #include #include void convert(long, char *); char *one[] = { "", "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine ", "Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen " }; char *ten[] = { "", "", "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety " }; int main() { long num; printf("Enter a number (max 9 digits): "); scanf("%ld", &num); if (num <= 0) { printf("Zero\n"); } else { printf("In words: "); // Indian System: Crore, Lakh, Thousand, Hundred convert((num / 10000000), "Crore "); convert(((num / 100000) % 100), "Lakh "); convert(((num / 1000) % 100), "Thousand "); convert(((num / 100) % 10), "Hundred "); convert((num % 100), ""); printf("\n"); } return 0; } void convert(long n, char *suffix) { if (n > 19) { printf("%s%s", ten[n / 10], one[n % 10]); } else { printf("%s", one[n]); } if (n > 0) { printf("%s", suffix); } }