Thread: C++ problem

  1. #1
    Registered User
    Join Date
    Oct 2001

    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
    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:


    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, 04: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, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM