Thread: for loop

  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
Website Security Test