Can anyone help me to break numbers into an array numbers

This is a discussion on Can anyone help me to break numbers into an array numbers within the C++ Programming forums, part of the General Programming Boards category; Hi, i was trying to make a program to brake the numbers into one array, for example user inputs 146, ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    2

    Exclamation Can anyone help me to break numbers into an array

    Hi, i was trying to make a program to brake the numbers into one array, for example user inputs 146, the program should take that int and put into the array(like that : array[0] = 1, array[2] = 4 and array[3] = 6. Can anyone help me with that? Please
    Last edited by s2xcracker; 08-25-2009 at 05:55 PM.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    Can you break the number apart with simple math? Figure out how to do that first and then you can convert to code.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    First step is to break up the original value into its digits. Start by writing a program that will print out each of the digits (1, 4, 6) separately. (hint: Use the / and % operators)

    Once that's done, you just need to stick those values into your array.
    bit∙hub [bit-huhb] n. A source and destination for information.

  4. #4
    Registered User
    Join Date
    Aug 2009
    Posts
    2
    Quote Originally Posted by bithub View Post
    First step is to break up the original value into its digits. Start by writing a program that will print out each of the digits (1, 4, 6) separately. (hint: Use the / and % operators)

    Once that's done, you just need to stick those values into your array.
    Yeah it's good idea, but the thing is that i am trying now and 2 weeks to separate them, and i know that it's a stupid question but can you give me an example. Please
    Last edited by s2xcracker; 08-25-2009 at 05:10 PM.

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by s2xcracker View Post
    Yeah it's good idea, but the thing is that i am trying now and 2 weeks to separate them, and i know that it's a stupid question but can you give me an example. Please
    Let me google that for you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newb Help: Full Arrays and Functions
    By LycanGalen in forum C Programming
    Replies: 5
    Last Post: 01-31-2008, 07:35 PM
  2. game window rejected painting !
    By black in forum Windows Programming
    Replies: 4
    Last Post: 03-27-2007, 01:10 AM
  3. ascii rpg help
    By aaron11193 in forum C Programming
    Replies: 18
    Last Post: 10-29-2006, 01:45 AM
  4. Replies: 27
    Last Post: 10-11-2006, 04:27 AM
  5. Converting Numbers to Words
    By denizengt in forum C Programming
    Replies: 20
    Last Post: 11-05-2003, 08:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21