Nested Loops

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AmLegacy
    New Member
    • Feb 2008
    • 6

    Nested Loops

    Hi, I'm trying to draw:
    0
    01
    012
    0123
    01234
    0123
    012
    01
    0
    So far I have the beginning for (i=1; i<=n; ++i)
    { for (j=0; j<i; ++j)
    {printf("%d ", j);}
    printf("\n" );
    }

    Does anyone know how to go backwards? I'm at my wits end.
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    You know that you can have loops that go backwards - start at a high number, end when the number is lower than 0, and decrement the counter - yes?

    Comment

    • AmLegacy
      New Member
      • Feb 2008
      • 6

      #3
      Would you add two new variables and nest a decremented double for loop? With k being greater than or equal to n?

      Comment

      Working...