Thread: Number to Words Program

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    76

    Number to Words Program

    **makes face like a three year old** I ask for a program to convert a number to words. for ex. 12345 -> one two three four five.

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    **Makes face like disappointed father** You should be ashamed for asking. I will not do your work for you. Do it yourself, however, and I will help you if get stuck.

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    76
    Code:
     String[] words = {"One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Zero"} ;
    how to separate digits from each other ? If I knew this, it would be easier for me to use if-elseif statements.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Hint: 12345 % 10 == 5; 12345 / 10 == 1234
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    If you move "Zero" to the start of the array then you can index it more naturally. i.e. words[0] would evaluate to "Zero", etc.

    In C the name of the type is char* not String

  6. #6
    Registered User
    Join Date
    Sep 2008
    Posts
    76
    thank you , all

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 12-02-2011, 09:19 PM
  2. Segmentation fault( counts number of words program )
    By paranoidgnu in forum C Programming
    Replies: 22
    Last Post: 05-12-2011, 04:08 PM
  3. a program that will make the number i input to words
    By janjan in forum C++ Programming
    Replies: 4
    Last Post: 02-14-2011, 07:16 PM
  4. Number of words multiplied by the number of lines in Linux
    By sjalesho in forum Linux Programming
    Replies: 2
    Last Post: 11-20-2003, 03:25 PM
  5. Program to show the number of occurrences of words...
    By Nutshell in forum C Programming
    Replies: 5
    Last Post: 01-26-2002, 06:44 PM