Hi all
I do understand nested for-loop when two for-loop is used but i get puzzled in case of three or more loops. I have surfed that on the internet but as a beginner in c++ i can't understand this, will someone explain it to me that how more than two For loop works.

2. If you understand a nested for loop, then increasing the number of nesting levels should not pose a problem to you in itself.

So, come up with an example of nested loops, and explain it. I'll take your explanation and extend it to yet another nesting level

3. You can explain this to yourself without a computer, use a pen and paper, or use three coins (big , medium, small will help to visualise) and draw three rows numbered 0 to 9 on a notepad, put the biggest coin on the 0 on top row, the medium coin on 0 on middle row and small one on 0 on bottom row, now move the counters according to how you think the loop works, and it will quickly come to you...if you can understand the descritption of my experiment that is.. ;->

4. Hello Aash
Here is one way to visualize what goes on as the for loops increase in number

1 For Loop
Code:
```for(int a = 0 ; a <= 1 ; a++) //from 0 to 1
cout << a << endl; //output current value of a with new line```
This would give
0
1

2 For Loops
Code:
```for(int a = 0 ; a <= 1 ; a++) //from 0 to 1
for(int b = 0 ; b <= 1 ; b++) //from 0 to 1
cout << a << b << endl; //output a,b and end line```
This would give
00
01
10
11

3 For Loops
Code:
```for(int a = 0 ; a <= 1 ; a++) //from 0 to 1
for(int b = 0 ; b <= 1 ; b++) //from 0 to 1
for(int c = 0 ; c <= 1 ; c++) //from 0 to 1
cout << a << b << c << endl; //output a,b,c and end line```
This would give
000
001
010
011
100
101
110
111

As you can see, a becomes longer and longer since it has to accommodate the For Loops within its own loop.
The range of a column (top-down) is independent from another.
You can see this by doing

3 For Loops
Code:
```    for(int a = 0 ; a <= 1 ; a++) //from 0 to 1
for(int b = 0 ; b <= 2 ; b++) //from 0 to 2
for(int c = 0 ; c <= 1 ; c++) //from 0 to 1
cout << a << b << c << endl; //output a,b,c and end line```
a b c
0 0 0
0 0 1
0 1 0
0 1 1
0 2 0
0 2 1
1 0 0
1 0 1
1 1 0
1 1 1
1 2 0
1 2 1

b's range is from 0 to 2, in this case.

Good luck

5. Thanks laserlight, rogster001

@CPlus thankyou for your nice effort, it's valuable.