+ 1

Is there any good example and clear concepetion regarding nested for loop ?

Nested for loop as can be draw multiple diamond pattern in one code.

12th Aug 2019, 10:20 AM
Manash Chakraborty Raju
Manash Chakraborty Raju - avatar
2 odpowiedzi
+ 5
yep, try processing how you can draw a diamond on a paper with a series of dots, using your own instruction one at a time like you want the diamond to be, like "when 9 is input, i use 9 space or more to get the pattern in the middle which will be controlled by a single for/while statement and another to print the star while you increment from one to 9 creating a triangle, and then create another inverse triangle to form a diamond using the same criteria earlier but in this case it start from 9 to 1" i hope you get this little explanation
12th Aug 2019, 10:39 AM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 2
Well the for loop simply keeps on executing the lines it covers again and again until the condition remains true... Now , put in another for loop into those lines of code and we get a nested for loop structure. Now with every iteration of our 'Parent' Loop the child loop will execute a variable number of times...
12th Aug 2019, 12:35 PM
Grizzly Gunner
Grizzly Gunner - avatar