C++ problem

This is a discussion on C++ problem within the C++ Programming forums, part of the General Programming Boards category; How can I write a program that when I input a five-digit number, it'll help me to separates the number ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    101

    C++ problem

    How can I write a program that when I input a five-digit number, it'll help me to separates the number into its individual digits and prints the digits separated from one another by three spaces each by using the integer division and modulus operators? thx!~

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    Well, as I bet this is a homework problem, here are hints, not answers:

    x % 10 is the remainder of x divided by 10, and
    x / 10 is the integer part of x divided by 10.

    These are related to the decimal digits of x. If you don't see how, break out a pencil and paper, and try doing long division (I hope you paid attention in 4th grade!) on the following numbers:

    76540
    45082
    66538

    Now, your quotient will be x/10, and your remainder is x%10. Once you've calculated the quotients and remainders it should be obvious how you should implement the program.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 05:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 09:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 03:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM

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