Thread: help on code

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

    help on code

    I was wondering if you’s could help me out with this problem. I want to display the following numbers in this format
    0:0
    1:0
    2:0
    3:0
    4:0
    and so on, but they come out on the screen like this 01234:0:0:0:0:0
    any ideas???heres my code, thanks

    #include <stdio.h>
    #include <conio.h>
    #define MAX 5
    int array[MAX];

    main()
    {
    int i, y;

    for(i=0; i<MAX; i++)
    {
    printf("%d", i);
    }

    for(y=10; y < 15; y++)
    printf(":%d", array[i + y]);

    getch();
    }

  2. #2
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Your printing out all of your 1st numbers in each pair all at once...
    1978 Silver Anniversary Corvette

  3. #3
    Unregistered
    Guest
    for (i=0;i++;i<whatever_number)
    printf("%i : 0\n",i);


    doesn't that do it?

  4. #4
    Unregistered
    Guest
    sorry I mean..

    for (i=0;i<whatever_number;i++)
    printf("%i : 0\n",i);

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    13

    also

    yeah, the above code will work fine, thanks, but i would like to use 2 for loops for this operation.

  6. #6
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Well, then you're going to have to have to one loop embedded in the other or it wouldn't work (aka your attempt)...
    1978 Silver Anniversary Corvette

  7. #7
    Registered User
    Join Date
    Oct 2001
    Posts
    13

    have it

    yeah, ive got it now, thanks !

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM