- A nested loop is a loop which is itself inside another loop. There is an inner loop withing the body of an outer loop.
- For example:
FOR i = 1 TO 5
FOR j = 1 TO 3
- Rule for nested loop.
- An outer loop and inner loop cannot have the same control variable.
- The inner loop must terminate before the outer loop.
- The inner loop must be completely nested inside the body of the outer loop.
- Outer loop is opened at first and closed at last.