This C++ command-line application converts integers into their word representation based on the Indian numbering system. It accepts integers as input and prints the corresponding number in words, making it especially useful for applications like cheques, bills, and reports that require textual representation of numbers.
./itw 52345
Output: Fifty-Two Thousand Three Hundred Forty-Five
- Supports Indian Number System (lakhs, crores, etc.).
- Efficiently breaks down numbers into logical units (units, tens, hundreds, thousands).
- Modular code structure with clear separation of logic, functions, and prototypes.
|-- itw.cpp # Main logic of the program
|-- functions.cpp # Functions for converting digits into words
|-- itw.h # Header file with function prototypes
|-- README.md # Project documentation (this file)
|-- LICENSE # License information
The program accepts integers as arguments and displays the corresponding number in words. Run the executable as follows:
./itw <integer>
./itw 4586
Output: Four Thousand Five Hundred Eighty-Six
./itw 123456
Output: One Lakh Twenty-Three Thousand Four Hundred Fifty-Six
- Numbers 0-19: These are hardcoded in an array for quick access (e.g.,
0 = ""
,1 = "One"
, ...19 = "Nineteen"
). - Tens (20-99): Numbers like "Twenty", "Thirty" are stored, and digits are appended (e.g.,
34 = "Thirty-Four"
). - Thousands and Lakhs: The application breaks the number into thousands, lakhs, crores, and converts each part into words.
- Optimized Handling: For numbers between 10,000 and 99,999, two digits are passed into the
thousands
variable, simplifying the conversion logic.
- Main Logic (
itw.cpp
): Controls the flow and handles input/output. - Functions (
functions.cpp
): Contains specific functions for each number range, making the code more readable and reusable. - Header (
itw.h
): Includes all function prototypes and constants for easy reference across the project.
- C++ compiler (g++ recommended)
- Command-line environment (Linux, MacOS, or Windows)
To compile the program, use the following command:
g++ itw.cpp functions.cpp -o itw
Once compiled, run the program as follows:
./itw <integer>
Example:
./itw 98304
- Decimal Handling: Add functionality to convert decimal numbers into words.
- Localization: Extend support for other number systems or languages.
- Error Handling: Improve input validation for non-integer inputs.
This project is licensed under the MIT License. See the LICENSE file for more details.
Contributions, issues, and feature requests are welcome! Feel free to check the issues page or submit a pull request.
👤 Aadhil Kassim
- GitHub: @AadhilKassim
- LinkedIn: Aadhil Kassim
Special thanks to Daniel Gakwaya and the FreeCodeCamp community for inspiring the C++ journey.
If you like this project, give it a ⭐️ on GitHub!