Results 1 to 2 of 2
Hi all,
I am required to write a program in an exercise of a book to transliterate a number into English. I can't make out the strategy. For being a ...
- 06-22-2008 #1Linux User
- Join Date
- Jun 2007
- Posts
- 458
Numeral to Alphabetical value
Hi all,
I am required to write a program in an exercise of a book to transliterate a number into English. I can't make out the strategy. For being a programmer, you need to write the strategy (what variables, functions, you'll be having) and that alone is a difficult task.
For example, 938 should be:
nine three eight
What to do?"When you have nothing to say, say nothing."
- 06-22-2008 #2
I would create and fill an array of ten elements (strings of the words).
Then a single figure of the number would correspond to the index of the array. e.g.
printf("%s\n", words[2].str());
would print out the word "Three" (index starts at 0) in a c++ program.
Of course, a number of several digits has to be broken down first to single figures. The modulus operation (mod or %) will be helpful here if you remember that the number is actually made of several figures which represent different powers of 10.


Reply With Quote