Find the answer to your Linux question:
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 ...
  1. #1
    Linux 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."

  2. #2
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...