What is Nested Loop? Define Nested Loop. Nested Loop Definition.
- 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:
- CLS
FOR i = 1 TO 5
FOR j = 1 TO 3
PRINT j;
NEXT j
PRINT
NEXT i
END
- 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.