
Loop Control Statements II-107
18. Write a program to illustrate an example of 'nested for' loops.
Ans:
Explanation: Here, in the above example, for each value of i, the inner loop's j
value varies from 1 to 2.
Outer loop executes three times whereas the inner loop executes six times. The inner loops terminates
when the value of j = 2 and the outer loop terminates when the value of i = 3. The total number of
iterations = outer loop iterations (3) * inner loop iterations (2) = 6.
19. Is it possible to create 'for' loop that never executes?
Ans: Yes, we can create 'for' loop that never executes when initial condition itself is not true. ...