Re: Nested for loop



f2prateek wrote:
I want my output to be something like this using only a single nested
for loop:-

*
**
***
****
*****
****
***
**
*

But I have not been able to do it using only one nested loop. I have
done it with two nested for loops, but need help in using only a
single for loop. Any suggestions?

If you could work out how to print out:

1 2 3 4 5 4 3 2 1

using only a single for loop, you'd be well on your way.
lex




.



Relevant Pages

  • Re: Newbie: whats Ruby idiom for word-by-word input?
    ... If you want to read to word boundaries only it becomes more difficult. ... you can use #getc and implement the word matching logic ... anyway the nested loop approach yields the proper result (aka sequence ...
    (comp.lang.ruby)
  • Re: How to break a while loop inside a switch statement?
    ... You have never needed out of a nested loop? ... There are times when a simple nested loop of 2-4ish levels is easier to ... read and maintain than having each loop level in its own method. ... latter might often require extra fields or parameters to be introduced ...
    (comp.lang.java.programmer)
  • Re: Simple Help with loops
    ... file=input('What is the name of the 2x2 matrix file to load? ... What can I do so that I can load any file in the correct directory the user inputs? ... The real question is whether he or she would consider this to be a nested loop. ...
    (comp.soft-sys.matlab)
  • Re: How to break a while loop inside a switch statement?
    ... You have never needed out of a nested loop? ... There are times when a simple nested loop of 2-4ish levels is easier to ... read and maintain than having each loop level in its own method. ... latter might often require extra fields or parameters to be introduced ...
    (comp.lang.java.programmer)
  • Re: resolve single line with multiple items into mutliple lines, single items
    ... This automatically leads to a nested loop, which you can use nicely to ... Recursion and loops are two different ways to achive the same result: ... repeating the execution of some code with modified data. ...
    (comp.lang.perl.misc)