for loop

This is a discussion on for loop within the C Programming forums, part of the General Programming Boards category; I kinda understand for loops. I need help.this is what I am tring to accomplish! 1 12 123 1234 12345 ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    1

    Thumbs up for loop

    I kinda understand for loops.
    I need help.this is what I am tring to accomplish!

    1
    12
    123
    1234
    12345
    123456
    1234567
    12345678
    123456789
    I know I need a for loop, but I get trapped using a for loop inside a for loop.

  2. #2
    Ethereal Raccoon Procyon's Avatar
    Join Date
    Aug 2001
    Posts
    189
    This should work...

    Code:
    for (maxnum = 1; maxnum <= 9; maxnum++)
    {
      for (num = 1; num <= maxnum; num++)
      {
        printf("%d", num);
      }
      printf("\n");
    }

Popular pages Recent additions subscribe to a feed

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