Printing Spaces between 5 digit integer

This is a discussion on Printing Spaces between 5 digit integer within the C Programming forums, part of the General Programming Boards category; I need direction. I am new to programming and was hoping for a pointer. I need to write a program ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    1

    Printing Spaces between 5 digit integer

    I need direction. I am new to programming and was hoping for a pointer. I need to write a program that inputs one 5 digit number and separates the number into individual digits and prints them separated by 3 spaces. Any ideas on how to accomplish this....

  2. #2
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511
    1. Use / and % to parse the numbers.

    2. Spacing: something like..

    Code:
     printf("3d%"x);
    not exactly what you need by similar.
    Mr. C: Author and Instructor

  3. #3
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    I hope you mean...

    Code:
    #include <stdio.h>
    
    
    int main ()
    {
         int d=5;
    
         printf("%3d", d);
         return 0;
    }
    but that's what you meant, right?

  4. #4
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511

    Thumbs up

    Yes that is what I meant I was just typing to fast!!
    Mr. C: Author and Instructor

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Changing 3 spaces to tabs
    By dnguyen1022 in forum C Programming
    Replies: 2
    Last Post: 12-22-2008, 12:51 AM
  2. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 10:42 AM
  3. Replies: 7
    Last Post: 08-19-2007, 09:10 AM
  4. Recognizing each digit of an integer
    By sybariticak47 in forum C++ Programming
    Replies: 3
    Last Post: 02-08-2006, 01:23 AM
  5. Operator Overloading (Bug, or error in code?)
    By QuietWhistler in forum C++ Programming
    Replies: 2
    Last Post: 01-25-2006, 08:38 AM

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